BCX Basic Forum

You must log on, to access files that were uploaded by BCX forum members. => Tips & Tricks => Topic started by: MrBcx on August 21, 2020, 09:46:22 PM

Title: Example of Multiple LOCAL datasets
Post by: MrBcx on August 21, 2020, 09:46:22 PM
'*************************************************************
' Here are two functions and a demo that shows how to define
' and use multiple local DATA sets using the READ$ function.
' This code is placed in the public domain by Kevin Diggins.
'*************************************************************

FUNCTION MONTH_NAME$ (i)
  SET DATA [] AS CONST PCHAR                  ' DATA must precede CODE that references it.
    "January","February","March","April",
    "May","June","July","August",
    "September","October","November","December"
  END SET
  IF i < 1 OR i > 12 THEN EXIT FUNCTION      ' Return an empty string
  FUNCTION = READ$(i)                              ' READ$() works well here too.
END FUNCTION



FUNCTION WEEKDAY_NAME$ (i)
  SET DATA [] AS CONST PCHAR
    "Sunday","Monday","Tuesday","Wednesday",
    "Thursday","Friday","Saturday"
  END SET
  IF i < 1 OR i > 7 THEN EXIT FUNCTION
  FUNCTION = READ$(i)
END FUNCTION

'---------------------------------------------
'              --  Begin Demo  --
'---------------------------------------------
CLS
PRINT "Here are the MONTH NAMES:"
PRINT

FOR INT i = 1 TO 12
  PRINT MONTH_NAME$(i)
NEXT

PRINT
PRINT "Here are the WEEKDAY NAMES:"
PRINT

FOR INT i = 1 TO 7
  PRINT WEEKDAY_NAME$ (i)
NEXT

PAUSE