|
Reverses specified string variable's contents. |
|
Original |
String passed to the procedure for reversal |
Reversed |
Reversed string |
|
global
procedure ReadLastINSer(string item,var string lastnr)
begin
record ItemHistVc IHr;
Integer i,l,a;
string 255 tstr,c;
LongInt li;
IHr.ArtCode = item;
for (i=0;i<30;i=i+1) begin
IHr.SerialNr = IHr.SerialNr & chr(125);
end;
if (ReadLastKey("ArtCodeSerialNr",IHr,2,false)) then begin
if (IHr.ArtCode==item) then begin
lastnr = IHr.SerialNr;
l = len(IHr.SerialNr);
for (i=l-1;i>=0;i=i-1) begin
c = Mid(IHr.SerialNr,i,1);
if (IsDigit(c)) then begin
tstr = tstr & c;
end else begin
a = i+1;
goto LBreakReadLastINSer;
end;
end;
LBreakReadLastINSer:;
c = "";
ReverseString(tstr,c);
if (nonblank(c)) then begin
li = StringToLongInt(c);
li = li + 1;
IHr.ArtCode = item;
IHr.SerialNr = Left(lastnr,a) & li;
if (ReadFirstKey("ArtCodeSerialNr",IHr,2,true)) then begin
lastnr = IHr.SerialNr;
end;
end;
end;
end;
return;
end;
««