-
Notifications
You must be signed in to change notification settings - Fork 39
Files
Aaron Niyonzima edited this page Jul 30, 2023
·
3 revisions
Reading text files(txt, csv, etc) in info basic is done in 3 steps:
- Open file using
OPENSEQ
- Read file (one line at time) using
READSEQ
- Close file using
CLOSESEQ
Let's write a simple program to read a csv file
PROGRAM MTD.ReadFile
dir = '../bnk.interface/EBANK.IN'
filename = 'transaction.csv'
OPENSEQ dir, filename TO ptr THEN
LOOP
READSEQ line FROM ptr ELSE BREAK
CRT line
REPEAT
END ELSE CRT 'Failed to open ': filename
CLOSESEQ ptr
END
Writing text files(txt, csv, etc) in info basic is done in 3 steps:
- Open file using
OPENSEQ
- Write data to a file using
WRITESEQ
- Close file using
CLOSESEQ
Let's write a simple logger in jBC
SUBROUTINE MTD.Logger(in_data, out_err)
err = ''
log_file = OCONV(DATE(), 'DG') : '.log'
log_line = OCONV(TIME(), 'MTS') : ' | ' : data
OPENSEQ '../bnk.log', log_file TO file_ptr THEN NULL
WRITESEQ log_line APPEND TO file_ptr ELSE err = 'Failed to write to ' : log_file
CLOSESEQ file_ptr
RETURN
END
- Home
- Getting started with InfoBasic(jbc)
- Key Features of InfoBasic
- Control Flow
- Subroutines and Functions
- OFS
- Template Programming
- T24 Integration with other Systems
- T24 Business Training
- T24 Navigation Training
- T24 Administration Training