qb45advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DATA Statement Programming Examples
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
DATA Statement Programming Examples
 
Example 1
 
The following example displays the current date by converting the
date returned by the DATE$ function.
 
' Get the date.
C$ = DATE$
' Use VAL to split the month off the string returned by
' DATE$.
FOR I% = 1 TO VAL(C$)
    READ Month$
NEXT
DATA January, February, March, April, May, June, July
DATA August, September, October, November, December
 
' Get the day.
Day$ = MID$(C$,4,2)
IF LEFT$(Day$,1) = "0" THEN Day$ = RIGHT$(Day$,1)
' Get the year.
Year$ = RIGHT$(C$,4)
 
PRINT "Today is " Month$ " " Day$ ", " Year$
 
Example 1 Sample Output
 
Today is September 21, 1988
 
Example 2
 
The following example shows how null data items are handled:
 
DATA abc,,def
DATA 1,,2
READ A$, B$, C$         'B$ = ""
PRINT A$, B$, C$
PRINT
READ A, B, C            'B = 0
PRINT A, B, C
 
Example 2 Sample Output
 
abc                     def
 1           0           2