so i fetch the position of ; and of : an then I compute the min() value, but i have to ignore the zero values ( e.g. no semicolon found )
Therefore, I designed this code
Code: Select all
Procedure minIntExceptZero( a.l, b.l )
If a = 0 : ProcedureReturn b ; if a = 0 return b, anyway if b = 0 or b > 0
ElseIf b = 0 : ProcedureReturn a ; a = 0 return b, anyway if b = 0 or b > 0
ElseIf a < b ; a > 0 und a < b. gib a zurück
ProcedureReturn a
Else
ProcedureReturn b
EndIf
EndProcedure
test$ = "a = 10 : b = 11 ; i will extract only: a=10"
posColon = FindString( test$, ":" )
posSemiColon = FindString( test$, ";" )
posCut = minIntExceptZero( posColon, posSemiColon )
Debug Trim( Left( test$, posCut - 1 ) )
Code: Select all
Procedure minIntExceptZero( a.l, b.l )
If a = 0 : ProcedureReturn b ; if a = 0 return b, anyway if b = 0 or b > 0
ElseIf b = 0 : ProcedureReturn a ; a = 0 return b, anyway if b = 0 or b > 0
ElseIf a < b ; a > 0 und a < b. gib a zurück
ProcedureReturn a
Else
ProcedureReturn b
EndIf
EndProcedure
Debug minIntExceptZero ( 1, 2 ) ; returns 1
Debug minIntExceptZero ( 0, 2 ) ; returns 2
Debug minIntExceptZero ( 3, 1 ) ; returns 1
Debug minIntExceptZero ( 3, 0 ) ; returns 3