[futurebasic] Re: [FB] READ?WRITE RECORDs

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 1999 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Wed, 29 Sep 1999 01:20:43 +0200

Warren Furman wrote:

> Hi all. I managed to do this sort of thing a few years back, but guess I'm
> getting dumber with age. Can someone tell me what I'm doing wrong?
>

Hi Warren,

What I would do is the following:

'READ/WRITE TEST
WINDOW 1

GLOBALS
DIM RECORD appointments
  DIM  6 dayt$
  DIM  6 tyme$
  DIM  4 ampm$
  DIM 30 who$
DIM END RECORD .appointmentsRec
REM dim a record variable
DIM appointment.appointmentsRec
END GLOBALS

LOCAL FN WriteRecord(recNum)
  volRefNum = SYSTEM(_aplVol)
  DEF OPEN "TEXT"
  OPEN "R",1,"appointments",_appointmentsRec,volRefNum
  RECORD #1, recNum
  REM write record variable
  WRITE  #1, appointment
  CLOSE 1
END FN

LOCAL FN ReadRecord(recNum)
  volRefNum = SYSTEM(_aplVol)
  DEF OPEN "TEXT"
  OPEN "R",1,"appointments",_appointmentsRec,volRefNum
  RECORD #1,recNum
  REM read the record into variable
  READ   #1, appointment
  CLOSE 1
END FN


DO
  SELECT INKEY$

    CASE "r"
      recNum = 1
      FN ReadRecord(recNum)
      REM print the fields of the record variable
      PRINT appointment.dayt$,appointment.tyme$;
      PRINT ,appointment.ampm$,appointment.who$

    CASE "w"
      recNum = 1
      REM fill the fields of the record variable
      appointment.dayt$ = "mm/dd"
      appointment.tyme$ = "00:00"
      appointment.ampm$ = "am"
      appointment.who$ = "Who?"
      FN WriteRecord(recNum)
      dayt$ = ""
      tyme$ = ""
      ampm$ = ""
      who$ = ""

  END SELECT
UNTIL FN BUTTON

HTH

Alain