Example:
Code: Select all
Result.s = UnLeft("GoodBye" , 3) ; Result will be "Good"
Result.s = UnRight("GoodBye" , 4) ; Result will be "Bye"
Code: Select all
Result.s = Left(Result, Len(Result) - 3)

Code: Select all
Result.s = UnLeft("GoodBye" , 3) ; Result will be "Good"
Result.s = UnRight("GoodBye" , 4) ; Result will be "Bye"
Code: Select all
Result.s = Left(Result, Len(Result) - 3)
Code: Select all
Macro UnLeft(string,length)
Left(string, Len(string) - length)
EndMacro
Macro UnRight(string,length)
Right(string, Len(string) - length)
EndMacro
Debug UnLeft("GoodBye" , 3) ; Result will be "Good"
Debug UnRight("GoodBye" , 4) ; Result will be "Bye"
Code: Select all
Procedure.s UnLeft(String.s, Length)
ProcedureReturn Left(String, Len(String) - Length)
EndProcedure
Procedure.s UnRight(String.s, Length)
ProcedureReturn Right(String, Len(String) - Length)
EndProcedure
don't see much use... doesn't this do the same?Booster698 wrote: Result.s = UnLeft("GoodBye" , 3) ; Result will be "Good"
Result.s = UnRight("GoodBye" , 4) ; Result will be "Bye"
Result.s = Left(Result, Len(Result) - 3)
Code: Select all
Procedure.s x_chop(string.s,left.l,right.l) ; chop a bit of the left and right side of a string
; *** chop 'n' characters from the left or right of a string
;
l = Len(string)
If right > 0
string = Left(string,l-right)
EndIf
If left > 0
string = Mid(string,left+1,l)
EndIf
;
ProcedureReturn string
;
EndProcedure
Code: Select all
a$ = "ABCDEFG"
b$ = a$(1 To 4) ; would return ABCD
b$ = a$(To 4) ; would return ABCD
b$ = a$(-4 to -7) ; would return ABCD
b$ = a$(-1 To -3) ; would return EFG
b$ = a$(-3 To 7) ; would return EFG
b$ = a$(5 To) ; would return EFG
b$ = a$ ; would return the whole string
I would rather like to see the existing commands enhanced:Booster698 wrote:It could be usefull to have these commands for strings manipulations :
Example:
Code: Select all
Result.s = UnLeft("GoodBye" , 3) ; Result will be "Good" Result.s = UnRight("GoodBye" , 4) ; Result will be "Bye"
Code: Select all
Result.s = Left("GoodBye" , -3) ; Result will be "Good"
Result.s = Right("GoodBye" , -4) ; Result will be "Bye"