How to convert A0058 value to 9958 in progress 4gl

2019-08-18 03:43发布

问题:

This question is an exact duplicate of:

  • How to convert A00073 value to 9973 in progress 4gl 5 answers

i have column having multiple value like A0045 ,A00065 . i want to convert it 9945, 9965. Need to remove all 0 and character value and add 99 before that value.. replace(val,"A","99") will replace only A I want to go for A-Z occurrence.. Any char should be convert .. Please help

回答1:

How about

newValue = "99" + LEFT-TRIM( oldValue, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ).

This should take all leading alpha and zero characters from the string, and prefix with 99.



回答2:

/************Try this*********************/

define variable word as character no-undo.

define variable i as integer no-undo.

assign word = "A00065".

/******to remove all the zeroes**************/

word = replace(word,substring(word,index(word,"0"),(r-index(word,"0") - 1)),"").

do i = 65 to 90:

   if substring(word,1,1) = chr(i) then 
   do:

      word = replace(word,substring(word,1,1),"99").
      leave.
   end. 


end. 

display word.