If I append a well running statement as the command of an If statement, it really should never happen that the well running statement is misinterpreteted.
- splits the line into comma separated array elements
- dispatches depending on element[0]
Peter
Posted 15 October 2007 - 12:11 PM
If I append a well running statement as the command of an If statement, it really should never happen that the well running statement is misinterpreteted.
Posted 15 October 2007 - 12:26 PM
Posted 15 October 2007 - 12:35 PM
Hard task..
Technically we are saying that wb needs to know when to ignore and recognize a comma as a separate component from a command.
At this moment everytime a comma is found it will split the rest of the line into another slot which is later used as the command wishes.
Using the special character allows to print a comma and this works.
----------
Adding this modification would mean adding special rules and complicate the language processing a lot..
Posted 15 October 2007 - 12:45 PM
A different alternity:Replacing all commas with special characters on the text part allows to print a comma anywhere - and this works.
IniWriteTextLine,"%PreISOScript%","Process","Exec,%ScriptFile%,pre-ISO"
Posted 15 October 2007 - 01:31 PM
Posted 15 October 2007 - 01:51 PM
Posted 15 October 2007 - 01:57 PM
You are a little bit wrong.I may be wrong, but i don't see the problem in fixing.
Every command knows exactly how many sections it has. No need to seperate after all comma. Just seperate up to the number of sections. The second command can then contain as many commas as it needs without confusing the first one.
Run,%ScriptFile%,my-dommand,#1,#2, ...But you are right as far that 'If' has 'command' as #4 or #5 (depending on how you count)
Posted 15 October 2007 - 02:09 PM
Each command should know how many components it will use - however this won't be possible when adding parameters on the run/exec commands or even on the if commands since these are not static to a few known parameters.
Then it will also be needed to change the default procedure that translate all special characters back to normal commas.
And this is something I'd really prefer to keep as it is before getting deeper and deeper into new bugs introduced by this modification.
The comma is used to split each part of the string and implementing this feature would make things very confusing and hard to assure good values when it simpler to just use #$c and know exactly what a comma does inside a command.
....
This is really asking to "guess" when a comma is no longer meant to be a comma..
Posted 15 October 2007 - 03:11 PM
Procedure run(text:string); begin text; end;
Posted 15 October 2007 - 03:23 PM
Procedure run(); begin statement; end;Than it cannot be that
Procedure run(); begin if somecondition then statement; end;only runs after modification of statement.
Posted 15 October 2007 - 06:05 PM
The if command can not have any number of sections, it's very clearly defined. And the run and exec commands can not have other WB commands following them. or can they?Each command should know how many components it will use - however this won't be possible when adding parameters on the run/exec commands or even on the if commands since these are not static to a few known parameters.
Posted 15 October 2007 - 06:24 PM
The if command can not have any number of sections, it's very clearly defined. And the run and exec commands can not have other WB commands following them. or can they?
Posted 15 October 2007 - 07:35 PM
I don't want to pressure you into anything, just show you a path you couldn't see before.Nice questions raised - but I'm really worried about the way how comma would be processed.
Please let me finish some of the new beta requests and I'll start working alongside with you and Peter to see if this is feasable.
Posted 15 October 2007 - 08:21 PM
If,%pCheckBox6%,Equal,true,IniWriteTextLine,"%PreISOScript%","Process","Exec,%ScriptFile%,pre-ISO1"is splitted currently like this:
1) If 2) %pCheckBox6% 3) Equal 4) true 5) IniWriteTextLine 6) "%PreISOScript%" 7) "Process" 8) "Exec 9)%ScriptFile% 10)pre-ISO1"
1) If 2) %pCheckBox6% 3) Equal 4) true 5) IniWriteTextLine 6) "%PreISOScript%" 7) "Process" 8) "Exec,%ScriptFile%,pre-ISO1"
Posted 15 October 2007 - 08:33 PM
but it should be like this:
1) If 2) %pCheckBox6% 3) Equal 4) true 5) IniWriteTextLine 6) "%PreISOScript%" 7) "Process" 8) "Exec,%ScriptFile%,pre-ISO1"
Posted 15 October 2007 - 08:40 PM
And that is the issue I'm trying to 'demand'
Peter
Posted 15 October 2007 - 08:56 PM
Here how I handle in my programs:Then the solution you suggested wasn't the best . The best would be to write a new function that splits the line in arguments and skip a comma if it is between quotes.
Edit: Forgot to mention that If this change is aplyed, winbuilder will no more need to find and replace #$c and #$s (that are VERY time consuming)
function handleQuotes(const inp: string): string;var TempString: string; TempList: Tstringlist; I: integer; inQuotes: boolean; tmp: string;begin TempList := TstringList.Create; TempString := ''; inQuotes := false; tmp := inp; repeat I := Pos('"', tmp); if i > 0 then begin TempString := copy(tmp, 0, i - 1); if inQuotes then tempString := AnsiReplaceText(tempString, ',', '|'); TempList.Append(tempString); tmp := copy(tmp, i + 1, Length(tmp)); inQuotes := not inQuotes; end; until i = 0; TempList.Append(Trim(tmp)); tempString := TempList.Strings[0]; for i := 1 to TempList.Count - 1 do begin tempString := tempString + '"' + TempList.Strings[i]; end; tmp := inp; handleQuotes := tempString;end;function split(input, delim: string): Tstringlist;var TempString: string; TempList: Tstringlist; I: integer;begin TempList := TstringList.Create; TempString := ''; if delim = ',' then input := handleQuotes(input); repeat I := Pos(delim, input); if i > 0 then begin TempString := Trim(copy(input, 0, i - 1)); TempString := AnsiReplaceStr(tempString, '|', ','); TempList.Append(TempString); input := copy(input, i + 1, Length(input)); end; until i = 0; TempList.Append(Trim(AnsiReplaceStr(input, '|', ','))); split := tempList;end;
Posted 15 October 2007 - 09:04 PM
Here how I handle in my programs:
Peter
Function StringSplit(line As String, out() As String, delimiter As String) As StringDim b() As ByteDim CharIndex As IntegerDim OldPos As IntegerDim qchar As IntegerDim dchar As IntegerDim index As IntegerDim temp As Integerqchar = Asc("""")dchar = Asc(delimiter)OldPos = 0b() = StrConv(line & delimiter, vbFromUnicode)ReDim Preserve out(0)CharIndex = 0Do'loop until a quote or delimiter is foundIf b(CharIndex) = qchar Then'Quote found. Loop until its pair is foundtemp = CharIndexDoCharIndex = CharIndex + 1If CharIndex > UBound(b ) ThenCharIndex = temp + 1Exit DoEnd IfLoop Until b(CharIndex) = qcharElseIf b(CharIndex) = dchar Then'Delimiter found. Alocate a new string and copy in it the contentsindex = UBound(out) + 1ReDim Preserve out(index)out(index) = String(CharIndex - OldPos, 0)MoveMemory out(index), ByVal VarPtr(b(0)) + OldPos, CharIndex - OldPosOldPos = CharIndex + 1End IfCharIndex = CharIndex + 1Loop Until CharIndex > UBound(b )End Function
Posted 15 October 2007 - 10:06 PM
Posted 16 October 2007 - 07:32 AM
Yes, it does. because it does not split on comma inside a quote pair.Peter, does the split function works exactly as you expect on this case?
0 members, 0 guests, 0 anonymous users