Code: Select all
While l
l-1
If PeekA(@a+l)=c
Break
EndIf
Wend
Code: Select all
While l
l-1
Until PeekA(@a+l)=c
Code: Select all
While l
l-1
If PeekA(@a+l)=c
Break
EndIf
Wend
Code: Select all
While l
l-1
Until PeekA(@a+l)=c
Code: Select all
While l
l-1
Until PeekA(@a+l)=c
; What happened to be here?
Code: Select all
Repeat
l-1
Until PeekA(@a+l)=c Or l=0
Code: Select all
Repeat
l-1
Until l <= 0 Or PeekA(@a+l)=c
Code: Select all
If #True Or CreateImage(1, 4, 4) ; CreateImage not execute!
Debug IsImage(1)
EndIf
The code was just a simple example for finding the position of a char in a string:STARGÅTE wrote:Both codes makes no sense [...] So you have to add here more querys...
Code: Select all
a.s="C:\abc\def\x.yz"
result=Len(a.s)
While result
result-1
;***
If PeekA(@a+result)='\'
Break
EndIf
Wend
Debug Left(a,result)
I think the traditional statements make it clear what is taking place. For instance, for your coding example I would use:Michael Vogel wrote:I know, that the code can be transformed into traditional statements but remember that usually there are many more statements (***) in a loop which would have to be executed in your examples.
Code: Select all
a.s="C:\abc\def\x.yz"
Result=Len(a.s)
If Result
Repeat
Result-1
;***
Until PeekA(@a+Result)='\' Or Result = 0
EndIf
Debug Left(a,Result)
In the meantime, I found out, why I did the request - I don't like the 'Break' command (and I do everything to avoid lines like 'Break 2')Demivec wrote:I think the traditional statements make it clear what is taking place.
Code: Select all
a.s="C:\abc\def\x.yz"
Result=0
While PeekA(@a+Result)<>'.'
Result+1
Until Result=Len(a)
Debug Left(a,Result)
Code: Select all
a.s = "C:\abc\def\x.yz"
Result = 1
While Result <> Len(a) And PeekA(@a+Result-1) <> '.'
Result + 1
Wend
Debug Left(a, Result)
a.s=""Little John wrote:No.Puffolino wrote:Shouldn't be Result<Len(a) ?
Yes, and Michael's pseudo code would give the same result.Puffolino wrote:a.s=""Little John wrote:No.Puffolino wrote:Shouldn't be Result<Len(a) ?
Result=1
:
Little John wrote:Yes, and Michael's pseudo code would give the same result.Puffolino wrote:a.s=""Little John wrote:No.Puffolino wrote:Shouldn't be Result<Len(a) ?
Result=1
:
So my code is a correct "translation" of his pseudo code.