qb45advr.hlp (Topic list)
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