Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?



Opens a file for sequential writing and/or reading. It takes the general form:

OPENSEQ Path{,File} {READONLY} TO FileVar{LOCKED statements} THEN|ELSE statements


  • Path specifies the relative or absolute path of the target directory or file,
  • File specifies additional path information of the target file,
  • FileVar contains the file descriptor of the file when the open was successful,
  • Statements are conditional jBASE BASIC statements.


If the file does not exist or cannot be opened it then executes the ELSE clause. However, if JBASICEMULATE is set for Sequoia (use value "seq") emulation then OPENSEQ will create the file if it does not exist. This behavior can also be achieved by specifying "openseq_creates = true" in Config_EMULATE for the emulation being used. Once open a lock is taken on the file. If the lock cannot be taken then the LOCKED clause is executed if it exists otherwise the ELSE clause is executed. If specified the READONLY process takes a read lock on the file, otherwise it takes a write lock. The specified file can be a regular, pipe or special device file. Locks are only taken on regular file types. Once open the file pointer is set to the first line of sequential data.

A program that uses sequential processing to create (write to)an ASCII text file from a jBASE hashed file is as below. It illustrates the use of the commands:


0001     $option jabba
0002 **set up working directory and file name here
0003     if getcwd(v.dir.in) then
0004         v.file.in = 'trial.txt'
0005     end
0008     openseq v.dir.in, v.file.in to f.file.in then
0009         crt 'file already exists'
0010     end  else
0011         crt 'file is being created....', v.file.in          ;*if openseq_creates=true
0012         stop
0013     end
0015 * open the jbase file
0016     open "dummy_records" to jbasefile else
0017         stop 201
0018     end
0019     select jbasefile          ;* process all records
0021 * now, let's loop thru each item and build the ascii text file.
0022     loop
0024     while readnext id do
0026         read myrec from jbasefile, id then
0027             line = myrec
0029 * process myrec and build the line variable with the information to be written to the ascii text file jbase automatically takes care of the
0030 *end-of-line delimiters in this case a cr/lf is appended to the end of each line however, this can be changed with the ioctl() function .
0032             writeseq line to v.file.in else
0033                 crt "what happened to the file?"
0034                 stop
0035             end
0036         end
0037     repeat
0039 * wrapup
0040     weofseq v.file.in
0041     closeseq v.file.in

A program that uses sequential processing to read from an ASCII text file and write to a jBASE hashed file is as below. It illustrates the use of the commands:


0001     $option jabba
0002 * First define the path to sequential file        
0003     if getcwd(directory) then
0004         path = directory:"\trial.txt"
0005     end
0007     openseq path to mypath else
0008         crt 'cannot find specified path or file'
0009         abort
0010     end
0012 * open the jbase file
0013     open "dummy_records" to jbasefile else stop 201
0015 *process the line data to obtain the record_id and assign it to the ID variable, record information to
0016 *myrec variable
0017     loop
0018         readseq line from mypath then
0019             write myrec to jbasefile, ID
0020         end else
0021             crt "Eroor writing to file ": jbasefile
0022         end
0023     repeat
0025 * wrapup
0026     closeseq mypath

Go back to jBASE BASIC.

Was this article helpful?