|
Gary, About 10
years ago I did something like that in VFP. In my case I was incrementing a 4
char job number. For what it is worth here is the code. The trick to is to
increment the ascii value of each character and track any carry. Bob
Branton MCI *vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv * Next JOB
NUMBER *------------------------------------------------------------------------ function
newjob private
old_jobnum,carry,i,new_jobnum,last_value dimension
dig(4) store
" " to dig(1),dig(2),dig(3),dig(4),old_jobnum,new_jobnum,last_value store
0 to i,carry *------------------------------- * get last JOB number *------------------------------- select
schedmas do
while ! rlock() enddo old_jobnum
= schedmas->sch_jobnum *=========================================== * find the next one *------------------------------------------- for i = 1
to 4 dig(i) = substr(old_jobnum,i,1) endfor carry = 1 for i = 4
to 1 step -1 last_value = asc(dig(i)) if carry = 1 last_value =
last_value + 1 endif do case case last_value >= 48 .and.
last_value <= 57 carry = 0 case last_value = 58 last_value = 65 carry = 0 case last_value >= 65 .and.
last_value <= 90 carry = 0 otherwise carry = 1 last_value = 48 endcase
*--------------------------------- * store NEW value
*--------------------------------- dig(i) = chr(last_value) endfor new_jobnum
= dig(1)+dig(2)+dig(3)+dig(4) select
schedmas replace
sch_jobnum with new_jobnum select
schedmas unlock return
(new_jobnum) *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -----Original
Message----- Is it possible to increment a text string? For example, if
I have a string, AAA, is it possible to automatically generate the next string
in a sequence, AAB, AAC, AAD ... AAZ, ABA, ABC, etc? Gary L. Alford |
<<attachment: image001.jpg>>
