Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace zeros with '' only before 1st number above 0
Message
From
19/09/2003 14:57:01
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Replace zeros with '' only before 1st number above 0
Miscellaneous
Thread ID:
00830748
Message ID:
00830748
Views:
60
Forgive me all, Friday afternoon and I'm brain dead again. It is hard to concentrate after Hurricane Isabel I guess. :o) I am importing a file and I bring in a field that is character but represents a numeric value. For instance, I will readin "00025000" which represents 25,000 but I need to transform it to "25" in character. "00100000" represents 100,000 but I need to convert it to "100" Should be simple, but I can't seem to get it right today for some reason. I will also readin "00000050" which is 50.00 (no thousands). Always 8 chars to readin. Any ideas?

Here's what I have so far:
covcode = ALLTRIM(SUBSTR(xdata,31,5))
premamt = VAL(SUBSTR(xdata,61,12))/100

Example 1 Data readin:
xdata = "6CVA159 3 W100035VEHR10001    BI   
991125000525???????????????????????????????????????????????????????0005000000100000?????????????????????????????????????????"

*--This one works correctly and returns 50/100 as it should for mcv_bodily
mcv_bodily = PADR(f_limit(xdata),9)

Example 2 Data Readin:
xdata="6CVA159 3 W100065VEHR10001    TL   991125000525???????????????????????????????????????????????????????00000050?????????????????????????????????????????????????"

*--This one returns too many zeros which are later cutoff when saved
*--It should return 50 but it returns 00000050
mcv_towing(crntveh) = SUBSTR(xdata,103,8)

FUNCTION f_limit
PARAMETER fdata
PRIVATE i,j
i = ALLTRIM(TRANS(VAL(SUBSTR(fdata,103,8))/1000,'@Z 99999'))
j = ALLTRIM(TRANS(VAL(SUBSTR(fdata,111,8))/1000,'@Z 99999'))
IF !EMPTY(j)
    i = i +'/'+j
ENDIF
RETURN i
TIA!!!
Tracy
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Next
Reply
Map
View

Click here to load this message in the networking platform