API Request
#1
Posted 21 August 2009 - 05:11 PM
But also @members who want to help Pedrole15 and me
Medevil asked me whether it is possible to get the value of a component of a different script.
I was thinking about adding to WinBuilder's commands, but then I thougt that this is too special for WB. It should be solved on script level.
That leads to API level.
The following code should be possible with WB 077 RC3:
Call:
GetInterface,%VarResult%,myscript,yourcomponent,type
Definition:
[Variables]
GetInterface=Run,%API%,Get_Interface,OUT:
Implementation:
[Get_Interface]
IniRead,#2,Interface,#3,%component%
If,#4,EQUAL,CheckBox,Set,%num%,8
If,#4,EQUAL,???,Set,%num%,???
If, ...
StrFormat,SPLIT,%component%,#$c,%num%,#1
(Untested, just a brainstorming suggestion) ...
To get the type, cannot be done automatically, because some scripts replace the standard names by their own mnemotechnic names.
Peter
#2
Posted 22 August 2009 - 02:06 AM
GetInterface=Run,%API%,Get_Interface,OUT:
I can't have the OUT: working
[main] Title=CodeBox test Description=Running custom commands [variables] GetInterface=Run,%ScriptFile%,Get_Interface %File%=%ProjectDir%\Apps\HijackThis!.script [process] GetInterface,VarResult,%File%,pTextBox1 Echo,"%VarResult%" [Get_Interface] IniRead,#2,Main,Interface,%_Interface_% If,%_Interface_%,Equal,,Set,%_Interface_%,Interface IniRead,#2,%_Interface_%,#3,%_Component_% If,#4,Equal,,Begin StrFormat,LTRIM,#3,1,%_CpntName_% Loop,%ScriptFile%,TrimNum,0,10 End Else,Set,%_CpntName_%,#4 Select_Case,%_CpntName_%,"TextBox|TextLabel|NumberBox|CheckBox|ScrollBox|RadioGroup|Image|TextFile|But ton|WebLabel|RadioButton|FileBox","8|1|8|8|1|8|1|1|8|8|8|1" Echo,"%Case%" StrFormat,SPLIT,%_Component_%,#$c,%Case%,%#1% If,%_CpntName_%,EQUAL,RadioGroup,Begin StrFormat,SPLIT,%_Component_%,#$c,0,#9 StrFormat,SPLIT,%_Component_%,#$c,#9,%#1% StrFormat,LEFT,%#1%,2,#8 If,#8,Equal,__,Begin StrFormat,DEC,#9,1 StrFormat,SPLIT,%_Component_%,#$c,#9,%#1% End End [TrimNum] StrFormat,REPLACE,%_CpntName_%,#c,,%_CpntName_%
#3
Posted 22 August 2009 - 03:36 PM
There has been a bug in the OUT functionality which is fixed now.Not easy to do
GetInterface=Run,%API%,Get_Interface,OUT:
I can't have the OUT: working
Thanks, Pedro for the code suggestion!
This works:
[variables] GetInterface=Run,%ScriptFile%,Get_Interface,OUT: %File%=%ProjectDir%\Apps\hxd.script [process] GetInterface,%VarResult%,%File%,pCheckBox1 Echo,"%VarResult%" [Get_Interface] IniRead,#2,Main,Interface,%_Interface_% If,%_Interface_%,Equal,,Set,%_Interface_%,Interface IniRead,#2,%_Interface_%,#3,%_Component_% If,#4,Equal,,Begin StrFormat,LTRIM,#3,1,%_CpntName_% Loop,%ScriptFile%,TrimNum,0,10 End Else,Set,%_CpntName_%,#4 Select_Case,%_CpntName_%,"TextBox|TextLabel|NumberBox|CheckBox|ScrollBox|RadioGroup|Image|TextFile|But ton|WebLabel|RadioButton|FileBox","8|1|8|8|1|8|1|1|8|8|8|1" Echo,"%Case%" StrFormat,SPLIT,%_Component_%,#$c,%Case%,#1 [TrimNum] StrFormat,REPLACE,%_CpntName_%,#c,,%_CpntName_%Take care of the #1 rather than %#1%
Peter
#4
Posted 23 August 2009 - 09:14 PM
GetInterface,%VarResult%,Filename,ComponentName[,Type][,Position]
WriteInterface,NewValue,Filename,ComponentName[,Type][,Position]
Example:
GetInterface,%Result%,%File%,pTextBox1 WriteInterface,"GetInterface Test",%File%,pTextBox1 // or GetInterface,%Result%,%File%,pTextBox1,TextBox,8 WriteInterface,"GetInterface Test",%File%,pTextBox1,TextBox,8 //Change position of pButton1 WriteInterface,340,%File%,pButton1,Button,4
Require WB077 RC3
GetInterface.script 5.43KB 615 downloads
Do I add this function to Api ?
Pedro
#5
Posted 24 August 2009 - 10:34 AM
If the variable %Result% don't exist it work well
but if it exist the value is inchanged
GetInterface,%Result%,%File%,pTextBox1 ==> OK %Result%="GetInterface Test" GetInterface,%Result%,%File%,pChekBox1 ==>Not OK %Result%="GetInterface Test"Or
Set,%Result%,Nil GetInterface,%Result%,%File%,pTextBox1 ==>Not OK %Result%=Nil
#6
Posted 24 August 2009 - 10:54 AM
Peter
#7
Posted 24 August 2009 - 10:57 AM
I suggest so. Perhaps you should temporarily a RC3 check.Do I add this function to Api ?
Great work, Pedro
Peter
#8
Posted 25 August 2009 - 09:30 AM
I do a typo in previous post and I confirm the OUT not overwrite existing variable
Pedro
#9
Posted 26 August 2009 - 02:01 PM
FixedI do a typo in previous post and I confirm the OUT not overwrite existing variable
(Hasn't been so easy )
Peter
#10
Posted 26 August 2009 - 06:07 PM
I am trying an other way more simple :
[variables] GetInterface2=Run,%ScriptFile%,Get_Interface2,OUT: %File%=%ProjectDir%\Apps\hxd.script [process] GetInterface,%VarResult%,%File%,pCheckBox1 Echo,"%VarResult%" [Get_Interface2] Set,#9,1 IniWriteTextLine,#2,Section_Get,"Set,##9,#$p#3#$p",Append Exec,#2,Section_Get,Out:#1 IniDeleteSection,#2,Section_Get
But not working OUT not supported by Exec
#11
Posted 26 August 2009 - 06:20 PM
The description of 'OUT' speaks about 'Run'OUT is not implemented for 'Exec' intentionally.'Exec' uses its own dataspace. It is like a completelly new processing the project. Therefore also the %ScriptFile%'s variables are unknown etc.I added 'Exec' some time ago, just because of the reason to be completelly independent from the calling script.#1, ... are generated for the 'Exec' and discarded when 'Exec' returns. You may say: 'Exec' is an 'external' process which cannot write into local process data.If this question is not only theoretical, but you have some certain reasons, I can think about a solution in WB 080, but not now.Thanks Peter
I am trying an other way more simple :
[code=auto:0][variables] GetInterface2=Run,%ScriptFile%,Get_Interface2,OUT: %File%=%ProjectDir%\Apps\hxd.script [process] But not working OUT not supported by Exec
Peter
#12
Posted 27 August 2009 - 06:47 AM
Thanks for the infoIf this question is not only theoretical, but you have some certain reasons, I can think about a solution in WB 080, but not now.
Don't break your head with that
I updated the WriteInterface in CAPI 12 Revision 1
It should work now in all case, even if there is comma in the string you want write
If there is space in string, quote are added
If you want add a quote in a string you may write #$q#$q
To change this in Interface
the code is:"StartNet" and "PENetwork" are license free!
pTextLabel1="""StartNet"" and ""PENetwork"" are license free!",1,1,10,0,410,25,9,Boldwith WriteInterface (ex :remove the word licence):
WriteInterface,"#$q#$qStartNet#$q#$q and #$q#$qPENetwork#$q#$q are free!",%File%,pTextLabel1To hide this label
WriteInterface,0,%File%,pTextLabel1,,2If ComponentName is not conventional you must specify ComponentType (same for GetInterface)
Ex: set the CheckBox named CheckBox_Ram to true
GetInterface,%Result%,%File%,CheckBox_Ram,CheckBox If,%Result%,Equal,False,WriteInterface,True,%File%,CheckBox_Ram,CheckBox
Pedro
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users