Jump to content











Photo
- - - - -

API Request


  • Please log in to reply
11 replies to this topic

#1 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 21 August 2009 - 05:11 PM

Mainly @Pedrole15

But also @members who want to help Pedrole15 and me :D

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 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 22 August 2009 - 02:06 AM

Not easy to do
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 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 22 August 2009 - 03:36 PM

Not easy to do
GetInterface=Run,%API%,Get_Interface,OUT:
I can't have the OUT: working

There has been a bug in the OUT functionality which is fixed now.

Thanks, Pedro for the code suggestion! :D
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 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 23 August 2009 - 09:14 PM

Syntax:
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
Attached File  GetInterface.script   5.43KB   615 downloads

Do I add this function to Api ?

Pedro

#5 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 24 August 2009 - 10:34 AM

The OUT is still not well working

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 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 24 August 2009 - 10:54 AM

Does is also not work when you write 'pCheckBox1' rather than 'pChekBox1'?

Peter :D

#7 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 24 August 2009 - 10:57 AM

Do I add this function to Api ?

I suggest so. Perhaps you should temporarily a RC3 check.

Great work, Pedro :D

Peter

#8 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 25 August 2009 - 09:30 AM

Added the 2 functions to CAPI 12
I do a typo in previous post and I confirm the OUT not overwrite existing variable

:D
Pedro

#9 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 August 2009 - 02:01 PM

I do a typo in previous post and I confirm the OUT not overwrite existing variable

Fixed :)

(Hasn't been so easy :D )

Peter

#10 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 26 August 2009 - 06:07 PM

Thanks Peter :ermm:
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 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 August 2009 - 06:20 PM

Thanks Peter :ermm:
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

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.

Peter

#12 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 27 August 2009 - 06:47 AM

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 for the info
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

"StartNet" and "PENetwork" are license free!

the code is:
pTextLabel1="""StartNet"" and ""PENetwork"" are license free!",1,1,10,0,410,25,9,Bold
with WriteInterface (ex :remove the word licence):
WriteInterface,"#$q#$qStartNet#$q#$q and #$q#$qPENetwork#$q#$q are free!",%File%,pTextLabel1
To hide this label
WriteInterface,0,%File%,pTextLabel1,,2
If 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

:frusty:
Pedro




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users