Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to strip characters to give numerical integer 1

Status
Not open for further replies.

JSeidel

Technical User
Jan 10, 2003
77
US
This is the formula I am using but I get an error - can anyone help me? I am trying to parse out characters that will either begin the field or be at the end of the field.

thanks

booleanVar L := false;
booleanVar R := false;
numberVar Ln := Length ({HChargeAudit.ChargeCode});
numberVar S := 0;
numberVar T := 0;
numberVar i;

for i := 1 to {@CDMCounter} step 1 do

if val({HChargeAudit.ChargeCode}[1]) in (0 to 9) then L = false else L = true;
if val({HChargeAudit.ChargeCode}[Ln]) in (0 to 9) then R = false else R = true;

if not L and not R then S = val({HChargeAudit.ChargeCode});
if not L and R then S = val({HChargeAudit.ChargeCode}[1 to Ln-1]);
if L and not R then S = val({HChargeAudit.ChargeCode}[2 to Ln]);
if L and R then S = val({HChargeAudit.ChargeCode}[2 to Ln-1]);

T = T + S;

{@SumCDMbyGroup} = T;
 
It would help if you could show a sample of your input and what it is you are looking for as output from the formula.

Thanks,
Thadeus
 
Sample input might be:

C1242D

R293593L

P2923X

Y3983920Z

I am looking for the following output:
1242
293593
2923
3983920
 
Will the Input always have a leading char and a trailing char or is that just the sample you provided?
Thanks, Thadeus
 
yes, it will always be in the form of leading or trailing. There will be no other variations
 
And the error you are getting is???

Jim Broadbent
 
I'm actually just getting all zeros - like my formula is reading everything as a 0.
 
If it's alway only one character then your numbers use:
val(mid({part},2))

If there can be more than one leading character, use:

numbervar looper;
numbervar out;
stringvar part:={@part};


for looper:= 1 to len(part) do (
if isnumeric(part[looper]) then
(out:=val(mid(part,looper));
looper:=len(part)));

out

Mike
 

Try this :

StringVar ValueCalc := "C1242D";
If NumericText(Left(ValueCalc,1)) = False then
Val(Mid(ValueCalc,2)) else
Val(ValueCalc)

Let me know how you get on........

Reebo
Scotland (Sunny with a Smile)
 
Reebo - thanks a million, the formula worked very well.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top