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?



The READV statement allows a program to read a specific field from a record in a previously opened file into a variable. It takes the general form:

READV variable1 FROM { variable2,} expression1, expression2 {SETTING setvar} {ON ERROR statements} {THEN|ELSE statements}


  • variable1 is the identifier into which the record will be read.
  • variable2 if specified, should be a variable that has previously been opened to a file using the OPEN statement. If variable2 is not specified, the default file variable is assumed.
  • expression1 should evaluate to a valid record key for the file.
  • expression2 should evaluate to a positive integer. If the number is invalid or greater than the number of fields in the record, a NULL string will be assigned to variable1. If the number is 0, then the readv0 emulation setting controls the value returned in variable1. If a non-numeric argument is evaluated, a run time error will occur. 
  • If the SETTING clause is specified and the read fails, setvar will be set to one of these values. If ON ERROR is specified, the statements following the ON ERROR clause will be executed for any Incremental File Errors except error 128.

If the READV is successful then the statements following THEN will be executed. If the READ is unsuccessful, i.e. the record key does not exist in the file, then the statements following ELSE are executed. If the READV is unsuccessful and there is no ELSE then expression is set to "" (null).

If it is desired to set a lock on a record, it should be done explicitly with the READU or READVU statement. To read a field from a previously opened file into a variable and take a read-only shared lock on the field, READVL may be used.

An example of use may be as:

001     OPEN "Customers" ELSE ABORT 201, "Customers"
002     OPEN "DICT Customers" TO DCusts ELSE ABORT 201, "DICT Customers"
003     READV Rec FROM DCusts, "Xref", 7 THEN
004         READ DataRec FROM Rec<7> ELSE ABORT 202, Rec<7>
005     END ELSE
006         ABORT 202, "Xref"
007     END

Go back to jBASE BASIC.

Was this article helpful?