Topic: Possible "bug" in "images.script"  (Read 14067 times)

Possible "bug" in "images.script"
« on: May 16, 2011, 09:22:51 PM »

sbaeder

  • *banned*
  • Jr. Chef
  • **
  • Date Registered: Apr 2011
  • Posts: 40
I got a funny text string when I went to save the WIM info...ila_rendered
Looks like it is inserting extra colon and quote character (now quotes aren't balanced?) for the following
Code: [Select]
WIMImageInfo_Name="Install.wim: 1 - Windows 7 Ultimate":",1,1,295,10,255,18,8,Bold
WIMImageInfo_Version="Version: 6.1.7601.17514":",1,1,300,35,250,18,8,Normal
WIMImageInfo_Arch="Architecture: x86":",1,1,300,75,250,18,8,Normal
WIMImageInfo_Language="Language: en-US":",1,1,300,95,250,18,8,Normal


[ Specified attachment is not available ]
« Last Edit: May 16, 2011, 09:35:02 PM by sbaeder »

Re: Possible "bug" in "images.script"
« Reply #1 on: May 16, 2011, 09:39:37 PM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 10350
let me guess (not tested here) , using wb080v3 fix ????

edit:
nope, there is bug.

@sbaeder,
make your tests with wb080rv3 before reporting.
« Last Edit: May 16, 2011, 09:57:08 PM by Lancelot »

Re: Possible "bug" in "images.script"
« Reply #2 on: May 16, 2011, 10:15:26 PM »

sbaeder

  • *banned*
  • Jr. Chef
  • **
  • Date Registered: Apr 2011
  • Posts: 40
Well, yes, the info I posted above was with the current "testing" version...

BUT, I get a different (worse?) error using the version supplied in the archive.

With a totally clean project installation area (just unpack the archive), and set the source location to an SP1 DVD directory, but without running first the save in the MAIN (i.e. first) configuration script, I get an empty value ila_rendered

I thought this may be because it couldn't retrieve the WIM tools, so I tried to run the 00-retrieve.script  to retrieve the wim tools.  It gave me an error about not finding Autoit (AU3361), since it had an empty value for the OS architecture???ila_rendered

This goes away if I do a "SAVE" in the top level configuration page!  BUT I still get empty values - just like the above screen shot. (that log is attached at end)...
And the values are still all "wacky" (i.e. the extra quote), but this time, WB (080v3) is all confused and doesn't display ANYTHING...

Code: [Select]
WIMImageInfo_Name="Install.wim: 5 - Windows 7 ULTIMATE":",1,1,295,10,255,18,8,Bold
WIMImageInfo_Version="Version: 6.1.7601.17514":",1,1,300,35,250,18,8,Normal
WIMImageInfo_SpLevel="Service Pack: SP1",1,1,300,55,250,18,8,Normal
WIMImageInfo_Arch="Architecture: x86":",1,1,300,75,250,18,8,Normal
WIMImageInfo_Language="Language: en-US":",1,1,300,95,250,18,8,Normal
WIMBootInfo_Name="Boot.wim: 2 - Microsoft Windows Setup",1,1,295,125,255,18,8,Bold

If I hack the script to use the NON-CAPI routines, it works as expected in both 80 and 81

Will test BOTH versions in the future, but this one seemed like a BUG from the get-go ( and now is confirmed!)...

Would also be a good idea if the retrieve script was "smart" enough to check variables like the OS X86 vs. X64 to get the right autoit executable...




[ Specified attachment is not available ]
« Last Edit: May 16, 2011, 10:18:18 PM by sbaeder »

Re: Possible "bug" in "images.script"
« Reply #3 on: May 16, 2011, 10:23:03 PM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 10350
edit:
(thanks editing sbaeder, hence previous removed)

Anyway, Let's wait what will ChrisR or Homes32 figure out.
« Last Edit: May 16, 2011, 10:24:56 PM by Lancelot »

Re: Possible "bug" in "images.script"
« Reply #4 on: May 16, 2011, 10:28:12 PM »

sbaeder

  • *banned*
  • Jr. Chef
  • **
  • Date Registered: Apr 2011
  • Posts: 40
Sure - no hard feelings...I still feel trying to get a working 81 is worth my time, and didn't mean to waste anyone elses...Just an oversight on my part...And of course, we want to make sure it works as expected with the version included!...

Haven't had the time yet to dig into the CAPI coding to see what is going on and why it is getting the index wrong and appending the extra characters on some lines but not others...

LATER!
 :thumbsup:

Re: Possible "bug" in "images.script"
« Reply #5 on: May 16, 2011, 10:40:52 PM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 10350
I still feel trying to get a working 81 is worth my time,
yep I thought like that for ~2 years, my last wasting my huge time & effort here http://www.boot-land.net/forums/index.php?showtopic=10327
after which I clearly understand it is totally wasting .

And of course, we want to make sure it works as expected with the version included!...

Haven't had the time yet to dig into the CAPI coding to see what is going on and why it is getting the index wrong and appending the extra characters on some lines but not others...

LATER!
 :thumbsup:
:thumbsup: I am glad you understand we prefer focusing this kind of things around here  :thumbup: and you can continue your other hoby at other places  :great:

I also currently do not have time to check what is going on too, testing other things tonight, if time left.......  :cheers:

Re: Possible "bug" in "images.script"
« Reply #6 on: May 17, 2011, 02:12:28 PM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 177
interesting. in some cases the 2 rightmost chars are not getting trimmed off. probably because of not counting the "" in the string length. possibly a bug since WriteInterface as that part of the code didn't really change.
« Last Edit: May 17, 2011, 02:18:08 PM by Homes32 »

Re: Possible "bug" in "images.script"
« Reply #7 on: May 17, 2011, 06:43:49 PM »

sbaeder

  • *banned*
  • Jr. Chef
  • **
  • Date Registered: Apr 2011
  • Posts: 40
Has something to do with if there is a SPACE in the original value - that is why the "service pack" entry is OK.  If you add a space in any of the strings then they are correct as well...And if you "fix" the values in the interface (to remove the extra quote), then they all have at least one space, and then on any re-run, they stay correct...

I thought it had something to do with adding the quotes if a space is detected inside the parameter, but that didn't solve it...

But somehow, when parsing the length of the parameter with or without the quotes, it gets the length wrong, and so, when finding the "right hand side" (with all the coordinates) to write back into the scriptfile, it is off by two, and so it includes the extra quote and comma, when it should split off the right hand side at the position of the comma in the complete string...

Gotta love all this string manipulation!  :embarrassed:

Re: Possible "bug" in "images.script"
« Reply #8 on: May 17, 2011, 07:07:40 PM »

sbaeder

  • *banned*
  • Jr. Chef
  • **
  • Date Registered: Apr 2011
  • Posts: 40
interesting. in some cases the 2 rightmost chars are not getting trimmed off. probably because of not counting the "" in the string length. possibly a bug since WriteInterface as that part of the code didn't really change.
Does the same thing in 80 and 81, and yes, could be a bug in WB, but I am still thinking it is in the CAP script, since it figures it out "right" if there is a space in the string, but not when the original input value on the interface parameter doesn't have any spaces in it...SO, while it could be the wrapping of the string in quotes, I think it is more complex than that...Just didn't have time to figure out the original logic and all the special cases it is trying to handle...

Re: Possible "bug" in "images.script"
« Reply #9 on: May 17, 2011, 07:52:54 PM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 177
definatly CAPI related. Haven't had much time to look in great detail. but the problem is the char cont for the Left trim getting off by 2, which results in the last 2 chars (:") getting left behind. this part of the code wasn't changed (that I remember) from the original WriteInterface function

all the string ops are a pain in the @$$. it would be much easier if the whole works could be split into an array, handled nice and clean like, the outputted back in to a string. unfortunately WB syntax is what we have so that is what we must work with. :(


Re: Possible "bug" in "images.script"
« Reply #10 on: May 18, 2011, 12:22:48 AM »

Galapo

  • Gena Baker
  • Grand Chef
  • *****
  • Location: Australia
  • Date Registered: Sep 2010
  • Posts: 2207
Can either of you post some code which illustrates the issue and the function(s) in question, then I can take a look at it?

Thanks,
Galapo.

Re: Possible "bug" in "images.script"
« Reply #11 on: May 18, 2011, 01:20:41 AM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 10350
Hi Galapo,

just made, here it is http://www.mediafire.com/?q712p8p4t228o9h

Re: Possible "bug" in "images.script"
« Reply #12 on: May 18, 2011, 01:24:12 AM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 177
Code: [Select]

[main]
Title=Interface Test
Description=ScriptInterface,Write Test
Selected=True
Level=5
Version=1

[variables]

[process]
Echo,"Write Interface info..."
ScriptInterface,Write,"Install.wim: Ultimate - 7",%scriptfile%,WIMImageInfo_Name
ScriptInterface,Write,"Version: 6.1.0.0",%scriptfile%,WIMImageInfo_Version
ScriptInterface,Write,"Service Pack: SP1",%scriptfile%,WIMImageInfo_SpLevel
ScriptInterface,Write,"Architecture: x86",%scriptfile%,WIMImageInfo_Arch
ScriptInterface,Write,"Language: en-us",%scriptfile%,WIMImageInfo_Language

[Interface]
WIMImageInfo_Name="Install.wim:",1,1,295,10,255,18,8,Bold
WIMImageInfo_Version="Version:",1,1,300,35,250,18,8,Normal
WIMImageInfo_SpLevel="Service Pack:",1,1,92,358,498,28,18,8,Normal
WIMImageInfo_Arch="Architecture:",1,1,300,75,250,18,8,Normal
WIMImageInfo_Language="Language:",1,1,300,95,250,18,8,Normal
WIMBootInfo_Name=Boot.wim:,1,1,92,390,498,27,12,Normal,125,255,18,8,Bold

this consistently borks.
between the 2 of us we should be able to figure out something :)
« Last Edit: May 18, 2011, 01:27:02 AM by Homes32 »

Re: Possible "bug" in "images.script"
« Reply #13 on: May 18, 2011, 03:47:52 AM »

Galapo

  • Gena Baker
  • Grand Chef
  • *****
  • Location: Australia
  • Date Registered: Sep 2010
  • Posts: 2207
Ok, try this (I also modified to introduce compatibility with 077rc2, functions remain untest by me with 080):

Code: [Select]
[_ScriptInterface]
// Parent Command for Interface Operations
// ScriptInterface,Command[,Parms]
Run,%API%,_ScriptInterface_#1,#2,#3,#4,#5,#6,#7,#8,#9

[_ScriptInterface_Read]
// ScriptInterface,Read,%VarResult%,Filename,ComponentName[,Position][,Interface]
// Read the value of an interface element from a different script than the currently executing one.
// #1=%VarResult% #2=FileName #3=ComponentName #4=Position #5=Interface
If,#2,Equal,,Set,#2,%ScriptFile%
If,Not,#5,Equal,,Set,%_Interface_%,#5
Else,Begin
IniRead,#2,Main,Interface,%_Interface_%
If,%_Interface_%,Equal,,Set,%_Interface_%,Interface
End
IniRead,#2,%_Interface_%,#3,%_Component_%
StrFormat,SPLIT,"%_Component_%",#$c,3,%_CpntType_%
If,#4,Bigger,0,StrFormat,SPLIT,"%_Component_%",#$c,#4,%tVar%
Else,Begin
// if no position specified use the "value" parmater
Select_Case,%_CpntType_%,"0|1|2|3|4|5|6|8|9|10|11|12|13|14","8|1|8|8|1|1|1|1|1|8|8|2|1|8"
StrFormat,SPLIT,"%_Component_%",#$c,%Case%,%tVar%
If,%_CpntType_%,EQUAL,14,Begin
//radiogroup type controls need extra work
StrFormat,SPLIT,"%_Component_%",#$c,0,#9
StrFormat,SPLIT,"%_Component_%",#$c,#9,%tVar%
StrFormat,LEFT,%tVar%,2,#8
If,#8,Equal,__,Begin
StrFormat,DEC,#9,1
StrFormat,SPLIT,"%_Component_%",#$c,#9,%tVar%
End
End
End
StrFormat,CTRIM,#1,#$p,%t%
Set,%%t%%,%tVar%

[_ScriptInterface_State]
// ScriptInterface,State,ComponentName[,State][,Filename][,RefreshInterface][,Interface]
// State=0(Hide) or 1(Visible) (If State is empty it is set to 1)
// Filename=If empty it is set to %ScriptFile%
// RefreshInterface=True or False
// Ex: ScriptInterface,State,CheckBox_Ram,0,,True
// #1=ComponentName #2=State #3=FileName #4=Refresh? #5=Interface
If,Not,#2,Equal,0,Set,#2,1
If,#3,Equal,,Set,#3,%ScriptFile%
If,Not,#5,Equal,,Set,%_Interface_%,#5
Else,Begin
IniRead,#3,Main,Interface,%_Interface_%
If,%_Interface_%,Equal,,Set,%_Interface_%,Interface
End
IniRead,#3,%_Interface_%,#1,%_Component_%
StrFormat,SPLIT,%_Component_%,#$c,1,%Cpnt1%
//StrFormat,Len,%Cpnt1%,%_LenCpnt1_%
_Calculate,StringLen('%Cpnt1%'),_LenCpnt1_
StrFormat,POS,%Cpnt1%,#$s,#9
If,#9,Bigger,0,Begin
If,#9,Smaller,%_LenCpnt1_%,Set,%Cpnt1%,#$q%Cpnt1%#$q
StrFormat,Inc,%_LenCpnt1_%,2
End
StrFormat,Inc,%_LenCpnt1_%,2
StrFormat,LTRIM,%_Component_%,%_LenCpnt1_%,%RightResult%
IniWrite,#3,%_Interface_%,#1,"%Cpnt1%#$c#2%RightResult%"
If,#4,Equal,True,System,REFRESHINTERFACE

[_ScriptInterface_Write]
// ScriptInterface,Write,NewValue,Filename,ComponentName[,Position][,Interface]
// #1=NewValue #2=FileName #3=ComponentName #4=ComponentPosition #5=Interface
If,#2,Equal,,Set,#2,%ScriptFile%
Set,%Pos_End%,0
_Calculate,"StringLen('#1')",_Len1_
StrFormat,POS,#1,#$s,#9
If,#9,Bigger,0,Begin
  If,#9,Smaller,%_Len1_%,Set,#1,#$q#1#$q
End
If,Not,#5,Equal,,Set,%_Interface_%,#5
Else,Begin
  IniRead,#2,Main,Interface,%_Interface_%
  If,%_Interface_%,Equal,,Set,%_Interface_%,Interface
End
IniRead,#2,%_Interface_%,#3,%_Component_%
StrFormat,SPLIT,"%_Component_%",#$c,3,%_CpntType_%
If,#4,Equal,,Begin
  // if no position specified use the "value" parmater
  Select_Case,%_CpntType_%,"0|1|2|3|4|5|6|8|9|10|11|12|13|14","8|1|8|8|1|1|1|1|1|8|8|2|1|8"
  Set,#4,%Case%
  If,%_CpntType_%,EQUAL,14,Begin
    //radiogroup type controls need extra work
    StrFormat,SPLIT,%_Component_%,#$c,0,#4
    StrFormat,SPLIT,%_Component_%,#$c,#4,#7
    StrFormat,LEFT,#7,2,#8
    If,#8,Equal,__,StrFormat,DEC,#4,1
  End
End
StrFormat,REPLACE,%_Component_%,#$q,|,%_tComponent_%
_Calculate,"StringLen('%_tComponent_%')",_LENComponent_
StrFormat,SPLIT,%_Component_%,"#$c",1,%Cpnt1%
StrFormat,POS,%_Component_%,%Cpnt1%,%CheckQuotes%
If,%CheckQuotes%,Bigger,1,Set,"%Cpnt1%","#$q%Cpnt1%#$q"
StrFormat,SPLIT,%Cpnt1%,#$q,0,%_Quote%
StrFormat,REPLACE,%Cpnt1%,#$q,|,%tCpnt1%
_Calculate,"StringLen('%tCpnt1%')",_LenCpnt1_
StrFormat,POS,%Cpnt1%,#$s,#9
If,#9,Bigger,0,Begin
  If,#9,Smaller,%_LenCpnt1_%,Set,%Cpnt1%,#$q%Cpnt1%#$q
  StrFormat,Inc,%_LenCpnt1_%,2
End
If,#4,Bigger,1,Begin
  StrFormat,Inc,%_LenCpnt1_%,1
  StrFormat,LTRIM,%_Component_%,%_LenCpnt1_%,%_Component2_%
  StrFormat,Dec,#4,1
  Set,%Pos_End%,%_LenCpnt1_%
  Loop,%API%,GetPos,1,#4,%_Component2_%
  If,%Pos_Star%,Equal,0,Set,%LeftResult%,""
  Else,StrFormat,LEFT,%_Component_%,%Pos_Start%,%LeftResult%
  If,%Pos_End%,Bigger,%Pos_Start%,Begin
    StrFormat,Dec,%Pos_End%,1
    StrFormat,LTRIM,%_Component_%,%Pos_End%,%RightResult%
  End
  Else,Set,%RightResult%,""
  IniWrite,#2,%_Interface_%,#3,"%LeftResult%#1%RightResult%"
End
Else,Begin
  If,%_Quote%,Bigger,2,StrFormat,Inc,%_LenCpnt1_%,%_Quote%
  StrFormat,LTRIM,%_Component_%,%_LenCpnt1_%,%RightResult%
  IniWrite,#2,%_Interface_%,#3,#1%RightResult%
End

[GetPos]
Set,%Pos_Start%,%Pos_End%
If,#c,Bigger,6,Begin
StrFormat,SPLIT,%_Component2_%,#$c,#c,#7
StrFormat,SPLIT,#7,#$q,0,#6
_Calculate,StringLen('#7'),_Param9_
Set,#9,%_Param9_%
StrFormat,POS,#7,#$s,#8
StrFormat,Inc,#9,#6
StrFormat,LTRIM,#1,#9,#1
If,#8,Bigger,0,StrFormat,Inc,#9,2
End
Else,Begin
StrFormat,POS,#1,#$c,#9
StrFormat,LTRIM,#1,#9,#1
End
StrFormat,INC,%Pos_End%,#9


Regards,
Galapo.

Re: Possible "bug" in "images.script"
« Reply #14 on: May 18, 2011, 06:22:40 AM »

Galapo

  • Gena Baker
  • Grand Chef
  • *****
  • Location: Australia
  • Date Registered: Sep 2010
  • Posts: 2207
Quote from: Nuno Brito (http://reboot.pro/14496/page__view__findpost__p__128929)
My apologies Homes32, but this is not correct.

@Homes32
Nice to see you trying to bring Nuno up-to-date on the facts regarding WB and CAPI.  :thumbsup:

But it's definitely an up-hill battle -- remember this is the guy who put forward the claim that RegAddBoot is the api command used to generate shortcuts and is not the command used for adding registry entries at boot.  :hyper:  :laughing: And when JonF tried to correct him on this kicked JonF out of the forum.  :thumbdown:

Good luck in your efforts, you need it!

Regards,
Galapo.
« Last Edit: May 18, 2011, 06:24:03 AM by Galapo »

Re: Possible "bug" in "images.script"
« Reply #15 on: May 18, 2011, 01:00:32 PM »

ChrisR

  • XPE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 3494
With a totally clean project installation area (just unpack the archive), and set the source location to an SP1 DVD directory, but without running first the save in the MAIN (i.e. first) configuration script, I get an empty value (Attachment Link)

I thought this may be because it couldn't retrieve the WIM tools, so I tried to run the 00-retrieve.script  to retrieve the wim tools.  It gave me an error about not finding Autoit (AU3361), since it had an empty value for the OS architecture???
yes indeed it was following the split scripts, to avoid this error, I added

Quote
[Process]
//run HostOSInfoMini if not done in main configuration
If,%OSArch%,Equal,"",Run,%scriptfile%,HostOSInfoMini
and section HostOSInfoMini

Re: Possible "bug" in "images.script"
« Reply #16 on: May 18, 2011, 01:22:44 PM »

ChrisR

  • XPE Baker
  • Grand Chef
  • *****
  • Date Registered: Mar 2011
  • Posts: 3494
I had not noticed the bug before, I had tried it before on variables that had spaces (images.script previously executed)  :embarrassed:.

actually, the problem is in images.script and not really in Capi  :wink:,

Label value without spaces are currently written with quotes, and this is the problem.
Quote
WIMImageInfo_Name="Install.wim:",1,1,295,10,255,18,8,Bold
ScriptInterface,Write,"Install.wim: %WIMIndex% - %WIMNAME%",%scriptfile%,WIMImageInfo_Name
   gives
WIMImageInfo_Name="Install.wim: 5 - Windows 7 ULTIMATE":",1,1,295,10,255,18,8,Bold


If I change the original script without quotes
Quote
WIMImageInfo_Name=Install.wim:,1,1,295,10,255,18,8,Bold
   gives
WIMImageInfo_Name="Install.wim: 5 - Windows 7 ULTIMATE",1,1,295,10,255,18,8,Bold
The API ScriptInterface is working properly here.


I also try by writing a value without spaces
Quote
WIMImageInfo_Arch=Architecture:,1,1,300,75,250,18,8,Normal
ScriptInterface,Write,"Architecture:%SourceArch%",%scriptfile%,WIMImageInfo_Arch
   gives
WIMImageInfo_Arch=Architecture:x86,1,1,300,75,250,18,8,Normal
The result is good too (without quote in label value).


shortly : a value without spaces should not have quotes and in this case the API "ScriptInterface,Write" seems to work properly.

In any case, I think changing the script to do as previously with txtreplace.

 :cheers:

Re: Possible "bug" in "images.script"
« Reply #17 on: May 18, 2011, 03:46:29 PM »

Homes32

  • Code Baker
  • Chef
  • ***
  • Date Registered: Dec 2010
  • Posts: 177
Ok, try this (I also modified to introduce compatibility with 077rc2, functions remain untest by me with 080):

Code: [Select]
[_ScriptInterface]
// Parent Command for Interface Operations
// ScriptInterface,Command[,Parms]
Run,%API%,_ScriptInterface_#1,#2,#3,#4,#5,#6,#7,#8,#9

[_ScriptInterface_Read]
// ScriptInterface,Read,%VarResult%,Filename,ComponentName[,Position][,Interface]
// Read the value of an interface element from a different script than the currently executing one.
// #1=%VarResult% #2=FileName #3=ComponentName #4=Position #5=Interface
If,#2,Equal,,Set,#2,%ScriptFile%
If,Not,#5,Equal,,Set,%_Interface_%,#5
Else,Begin
IniRead,#2,Main,Interface,%_Interface_%
If,%_Interface_%,Equal,,Set,%_Interface_%,Interface
End
IniRead,#2,%_Interface_%,#3,%_Component_%
StrFormat,SPLIT,"%_Component_%",#$c,3,%_CpntType_%
If,#4,Bigger,0,StrFormat,SPLIT,"%_Component_%",#$c,#4,%tVar%
Else,Begin
// if no position specified use the "value" parmater
Select_Case,%_CpntType_%,"0|1|2|3|4|5|6|8|9|10|11|12|13|14","8|1|8|8|1|1|1|1|1|8|8|2|1|8"
StrFormat,SPLIT,"%_Component_%",#$c,%Case%,%tVar%
If,%_CpntType_%,EQUAL,14,Begin
//radiogroup type controls need extra work
StrFormat,SPLIT,"%_Component_%",#$c,0,#9
StrFormat,SPLIT,"%_Component_%",#$c,#9,%tVar%
StrFormat,LEFT,%tVar%,2,#8
If,#8,Equal,__,Begin
StrFormat,DEC,#9,1
StrFormat,SPLIT,"%_Component_%",#$c,#9,%tVar%
End
End
End
StrFormat,CTRIM,#1,#$p,%t%
Set,%%t%%,%tVar%

[_ScriptInterface_State]
// ScriptInterface,State,ComponentName[,State][,Filename][,RefreshInterface][,Interface]
// State=0(Hide) or 1(Visible) (If State is empty it is set to 1)
// Filename=If empty it is set to %ScriptFile%
// RefreshInterface=True or False
// Ex: ScriptInterface,State,CheckBox_Ram,0,,True
// #1=ComponentName #2=State #3=FileName #4=Refresh? #5=Interface
If,Not,#2,Equal,0,Set,#2,1
If,#3,Equal,,Set,#3,%ScriptFile%
If,Not,#5,Equal,,Set,%_Interface_%,#5
Else,Begin
IniRead,#3,Main,Interface,%_Interface_%
If,%_Interface_%,Equal,,Set,%_Interface_%,Interface
End
IniRead,#3,%_Interface_%,#1,%_Component_%
StrFormat,SPLIT,%_Component_%,#$c,1,%Cpnt1%
//StrFormat,Len,%Cpnt1%,%_LenCpnt1_%
_Calculate,StringLen('%Cpnt1%'),_LenCpnt1_
StrFormat,POS,%Cpnt1%,#$s,#9
If,#9,Bigger,0,Begin
If,#9,Smaller,%_LenCpnt1_%,Set,%Cpnt1%,#$q%Cpnt1%#$q
StrFormat,Inc,%_LenCpnt1_%,2
End
StrFormat,Inc,%_LenCpnt1_%,2
StrFormat,LTRIM,%_Component_%,%_LenCpnt1_%,%RightResult%
IniWrite,#3,%_Interface_%,#1,"%Cpnt1%#$c#2%RightResult%"
If,#4,Equal,True,System,REFRESHINTERFACE

[_ScriptInterface_Write]
// ScriptInterface,Write,NewValue,Filename,ComponentName[,Position][,Interface]
// #1=NewValue #2=FileName #3=ComponentName #4=ComponentPosition #5=Interface
If,#2,Equal,,Set,#2,%ScriptFile%
Set,%Pos_End%,0
_Calculate,"StringLen('#1')",_Len1_
StrFormat,POS,#1,#$s,#9
If,#9,Bigger,0,Begin
  If,#9,Smaller,%_Len1_%,Set,#1,#$q#1#$q
End
If,Not,#5,Equal,,Set,%_Interface_%,#5
Else,Begin
  IniRead,#2,Main,Interface,%_Interface_%
  If,%_Interface_%,Equal,,Set,%_Interface_%,Interface
End
IniRead,#2,%_Interface_%,#3,%_Component_%
StrFormat,SPLIT,"%_Component_%",#$c,3,%_CpntType_%
If,#4,Equal,,Begin
  // if no position specified use the "value" parmater
  Select_Case,%_CpntType_%,"0|1|2|3|4|5|6|8|9|10|11|12|13|14","8|1|8|8|1|1|1|1|1|8|8|2|1|8"
  Set,#4,%Case%
  If,%_CpntType_%,EQUAL,14,Begin
    //radiogroup type controls need extra work
    StrFormat,SPLIT,%_Component_%,#$c,0,#4
    StrFormat,SPLIT,%_Component_%,#$c,#4,#7
    StrFormat,LEFT,#7,2,#8
    If,#8,Equal,__,StrFormat,DEC,#4,1
  End
End
StrFormat,REPLACE,%_Component_%,#$q,|,%_tComponent_%
_Calculate,"StringLen('%_tComponent_%')",_LENComponent_
StrFormat,SPLIT,%_Component_%,"#$c",1,%Cpnt1%
StrFormat,POS,%_Component_%,%Cpnt1%,%CheckQuotes%
If,%CheckQuotes%,Bigger,1,Set,"%Cpnt1%","#$q%Cpnt1%#$q"
StrFormat,SPLIT,%Cpnt1%,#$q,0,%_Quote%
StrFormat,REPLACE,%Cpnt1%,#$q,|,%tCpnt1%
_Calculate,"StringLen('%tCpnt1%')",_LenCpnt1_
StrFormat,POS,%Cpnt1%,#$s,#9
If,#9,Bigger,0,Begin
  If,#9,Smaller,%_LenCpnt1_%,Set,%Cpnt1%,#$q%Cpnt1%#$q
  StrFormat,Inc,%_LenCpnt1_%,2
End
If,#4,Bigger,1,Begin
  StrFormat,Inc,%_LenCpnt1_%,1
  StrFormat,LTRIM,%_Component_%,%_LenCpnt1_%,%_Component2_%
  StrFormat,Dec,#4,1
  Set,%Pos_End%,%_LenCpnt1_%
  Loop,%API%,GetPos,1,#4,%_Component2_%
  If,%Pos_Star%,Equal,0,Set,%LeftResult%,""
  Else,StrFormat,LEFT,%_Component_%,%Pos_Start%,%LeftResult%
  If,%Pos_End%,Bigger,%Pos_Start%,Begin
    StrFormat,Dec,%Pos_End%,1
    StrFormat,LTRIM,%_Component_%,%Pos_End%,%RightResult%
  End
  Else,Set,%RightResult%,""
  IniWrite,#2,%_Interface_%,#3,"%LeftResult%#1%RightResult%"
End
Else,Begin
  If,%_Quote%,Bigger,2,StrFormat,Inc,%_LenCpnt1_%,%_Quote%
  StrFormat,LTRIM,%_Component_%,%_LenCpnt1_%,%RightResult%
  IniWrite,#2,%_Interface_%,#3,#1%RightResult%
End

[GetPos]
Set,%Pos_Start%,%Pos_End%
If,#c,Bigger,6,Begin
StrFormat,SPLIT,%_Component2_%,#$c,#c,#7
StrFormat,SPLIT,#7,#$q,0,#6
_Calculate,StringLen('#7'),_Param9_
Set,#9,%_Param9_%
StrFormat,POS,#7,#$s,#8
StrFormat,Inc,#9,#6
StrFormat,LTRIM,#1,#9,#1
If,#8,Bigger,0,StrFormat,Inc,#9,2
End
Else,Begin
StrFormat,POS,#1,#$c,#9
StrFormat,LTRIM,#1,#9,#1
End
StrFormat,INC,%Pos_End%,#9


Regards,
Galapo.
sorry. no change in results. :(

Re: Possible "bug" in "images.script"
« Reply #18 on: May 18, 2011, 04:57:58 PM »

sbaeder

  • *banned*
  • Jr. Chef
  • **
  • Date Registered: Apr 2011
  • Posts: 40
actually, the problem is in images.script and not really in Capi  :wink:,

Label value without spaces are currently written with quotes, and this is the problem.
Shouldn't it be able to work either way?  Yes, we all know that the quotes aren't necessary if there are no spaces, but they shouldn't be an issue if they do exist.

All the parsing is a pain in the butt...The more I think about it, the more I think a general purpose function isn't possible.  Different types of interface parameters have different numbers of parameters. At lease we can know that if you enter a Comma inside a lable, the interface just encapsulates it inside quotes, and if a quote is added inside a value, it is transformed to a #$q...So, you have to see if there are quotes, and do "the right thing...
« Last Edit: May 18, 2011, 06:26:57 PM by sbaeder »

Re: Possible "bug" in "images.script"
« Reply #19 on: May 18, 2011, 06:47:05 PM »

sbaeder

  • *banned*
  • Jr. Chef
  • **
  • Date Registered: Apr 2011
  • Posts: 40
Ok, try this (I also modified to introduce compatibility with 077rc2, functions remain untest by me with 080):
sorry. no change in results. :(
I think there is a change!  Seems to work OK for quoted and non-quoted strings in the text label.   BUT, there is also a delta between it and 81  :wink:

Looks like 80 and older can't handle an embedded comma or quote in the strings!  With this change in 81, AND an embedded #$q inside the original label, then this CAPI fix gets confused, and treats it as the end of the string.
« Last Edit: May 18, 2011, 07:23:08 PM by sbaeder »

 

Powered by EzPortal