# Adding / subtracting decimals from text files

Anybody got any old snippets for adding/subtracting decimals from machine code? The files are text, and the numeric value follows the address word. (X,Z,I,J etc.)An example would be X26.2 would convert to X262000. (always 4 places from the right without the decimal) An expanded example might look like:
X26.2Y13.702Z9.745F.0070 --> Converted X262000Y137020Z97450F0070
...hopefully somebody out there has already fought this battle and I don't have to muddle thru.

thx, Jake

include123@aol.com

• [b][red]This message was edited by DrMarten at 2005-3-16 19:8:57[/red][/b][hr]
: Anybody got any old snippets for adding/subtracting decimals from machine code? The files are text, and the numeric value follows the address word. (X,Z,I,J etc.)An example would be X26.2 would convert to X262000. (always 4 places from the right without the decimal) An expanded example might look like:
: X26.2Y13.702Z9.745F.0070 --> Converted X262000Y137020Z97450F0070
: ...hopefully somebody out there has already fought this battle and I don't have to muddle thru.
:
: thx, Jake
:
: include123@aol.com
:

This code is BASIC "testfile.txt" should be replaced with your filename.

This works in LIBERTY BASIC giving the result you want>!

5 on error goto 160
10 Open "c: estfile.txt" for input as #f
15 Rem:Get past the 1st character if it is always an X,Y or Z
20 a\$=input\$(#f,lof(#f))
30 Print a\$;
35 count=1
45 count=count+1
50 IF a\$<>"." then print a\$
60 If a\$="." then goto 40
70 If a\$="X" and count<6 then print"0";
80 If a\$="Y" and count<6 then print"0";
90 If a\$="Z" and count<6 then print"0";
100 If eof=-1 then goto 150
110 If count=6 then count=0:goto 35
120 goto 40
150 CLOSE #f
160 Close #f:END