Task

Increment a numerical string.




string 0;               \use zero-terminated string convention
code Text=12;
 
func StrLen(A);         \Return number of characters in an ASCIIZ string
char A;
int  I;
for I:= 0 to -1>>1-1 do
        if A(I) = 0 then return I;
 
proc IncStr(S);         \Increment a numeric string
char S;
int  I;
[for I:= StrLen(S)-1 downto 0 do
        [S(I):= S(I)+1;
        if S(I) > ^9 then S(I):= S(I)-10 else return;
        ];
];
 
char Str;
[Str:= "0123999999999"; \MSD first (big endian)
IncStr(Str);  IncStr(Str);
Text(0, Str);
]