;Copyright 2000 - Mark McDonald All rights reserved ; DECLARE: FUNCTION GETNSEQ$(BYVAL string) ; GETNSEQ(STRING) ; Returns a string where STRING is incremented. ; EXAMPLE: T$ = GETNSEQ("ABCD-8") 'ABCD-9' Extrn Get$Loc: far Extrn Get$Alloc: far MCODE Segment Byte Public Assume CS: MCODE Public GETNSEQ GETNSEQ Proc Far ARG StrHandle: WORD = Retbytes push BP ; mov BP,SP ; push DS ; mov AX,StrHandle ; put string handle in AX push AX ; push it on the stack call Get$Loc ; call PowerBASIC mov DS,DX ; put segment in DS mov SI,AX ; put offset in SI xor AX,AX ; assume a null string jcxz Exit ; is it null? push CX ; push length for Get$Alloc call Get$Alloc ; allocate a new string push AX ; save handle on stack for exit push AX ; push it on stack for Get$Loc call Get$Loc ; get location of string mov ES,DX ; put segment in ES mov DI,AX ; put offset in DI add SI,CX ; point SI to last char in source$ dec SI ; make it 0 based add DI,CX ; point DI to last char in new string dec DI ; make it 0 based mov DX,1 ; use DX as a boolian std ; set the direction flag CheckChar: lodsb ; get a char from source$ cmp DX,0 ; does DX=0? je WriteChar ; yes, were done with the sequence cmp AL,48 ; is char "0"? jb WriteChar ; less, so move it cmp AL,57 ; is char "9"? jbe DoSequence ; less or equal so do sequence cmp AL,65 ; is char "A"? jb WriteChar ; less than "A", not a number, move it cmp AL,90 ; is char "Z"? jbe DoSequence ; less or equal so do sequence cmp AL,97 ; is char "a"? jb WriteChar ; less than "a", not alpha, move it cmp AL,122 ; is char "z"? jbe DoSequence ; less or equal so do a sequence WriteChar: stosb ; put char in new strings loop CheckChar ; do it CX times pop AX ; get string handle Exit: pop DS ; pop BP ; retf Retbytes ; DoSequence: xor DX,DX ; assume we don't have to do this anymore inc AL ; add one to char cmp AL,58 ; did we go past "9"? jne CheckUpper ; see if were dealing with upper case mov AL,48 ; make it "0" mov DX,1 ; we gotta do it again jmp Short WriteChar ; move char CheckUpper: cmp AL,91 ; did we go past "Z"? jne CheckLower ; see if were dealing with lowercase mov AL,65 ; make it "A" mov DX,1 ; we gotta do it again jmp Short WriteChar ; move char CheckLower: cmp AL,123 ; did we go past "z"? jne WriteChar ; nope, so move the char mov AL,97 ; make it "a" mov DX,1 ; we gotta do it again jmp Short WriteChar ; move char GETNSEQ EndP MCODE EndS End