Web Bug from cid:[EMAIL PROTECTED]

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-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Alford, Gary L
Sent: Wednesday, January 19, 2005 7:12 AM
To: DFW ColdFusion Users Group (E-mail)
Subject: Incrementing Text Strings

 

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
Manufacturing Operations Project Specialist
Bell Helicopter XWorx
Phone: (817) 280-6233     Fax: (817) 278-6233
[EMAIL PROTECTED]


 

<<attachment: image001.jpg>>

Reply via email to