Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
QBasic Random Data Files
Message
From
29/12/2000 09:45:51
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00456801
Message ID:
00457735
Views:
33
>Good morning, Ron.
>
>I received the files today. I'm cheking them. I think I'll send you a little QBASIC program for you to use as a template for converting all your data.

Here it is, Ron.

Maybe George or something else could perfect the code, but it works. I've sent it to you with a test file and other pieces.
'Here I declare the source and target filenames
DataSource$ = "test.ron"
DataTarget$ = "test.txt"

'This is the structure definition
'You just have to specify the length of the strings
TYPE roRecord
    roStr      AS STRING * 20
    roInt      AS INTEGER
    roLong     AS LONG
    roSingle   AS SINGLE
    roDouble   AS DOUBLE
END TYPE

'Here we create a variable from that structure
'Think about this as a kind of scatter memvar blank
DIM rs AS roRecord

'Let's open the source
OPEN DataSource$ FOR RANDOM AS #1 LEN = LEN(rs)

'...and the target
OPEN DataTarget$ FOR OUTPUT AS #2

'Set our record counter
DIM recc AS INTEGER
recc = 0

'Scan trough the file
DO
    recc = recc + 1
    GET #1, recc, rs

    PRINT #2, rs.roStr;
    PRINT #2, USING "########"; rs.roInt;
    PRINT #2, USING "############"; rs.roLong;
    PRINT #2, USING "########.#######"; rs.roSingle;
    PRINT #2, USING "############.#######"; rs.roDouble

LOOP UNTIL (EOF(1))


CLOSE #1
CLOSE #2
This is quite generic. I think it's easy to adapt it. Also, as you can imagine, the USING mask could be as you want. In most cases Single and Doubles would have two decimals places, and the like. You can even define a couple variables IntMask$ and FloatMask$ and use each one to handle both integer or floating point types.

Hope this helps. If not, just shout! I'll hear you. 8-)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform