How to convert A0058 value to 9958 in progress 4gl [duplicate]

走远了吗. 提交于 2019-12-11 17:18:53

问题


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.


来源:https://stackoverflow.com/questions/46929456/how-to-convert-a0058-value-to-9958-in-progress-4gl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!