Page 1 of 1

Read and Write Records

Posted: Sun Jul 16, 2017 6:45 pm
by alxfrnds
Hi guys, can someone provide an example for read and write file records?
my records are in a structure, I can use random access because the record size is fixed with fixed length strings and other data, for example:

Code: Select all

Structure AcctRecord
    User.s{80}
    Password.s{30}
    EAddress.s{80}
    EPass.s{30}
    USign.s{141}
    AlwaysSign.i
    AlwaysTag.i
    Ed.s{64}
    Fore.i
    Back.i
    intMusic.i
    QuoteSymbol.s{2}
    Thrd.i
    Rnb.i
    MDir.s{40}
    DownDir.s{40}
    Font.s{12}
    DefMenu.i
    DefOpts.i
    Tp.s{30}[10]
    Script.s{12}[10]
    Rotate.i
    HNSUrn.s{4}
    POP3Url.s{64}
    SMTPUrl.s{64}
    NNTPUrl.s{64}
    ShowAll.s{1}
    TimeMonth.l[10]
    LogEMail.s{32}
    Defaults.i
    UBirthday.s{3}
    AltDNS.s{4}
    RealName.s{80}
    SetName.s{20}
    MyIP.l
    Padd.s{56}
EndStructure
With QBASIC I would use something like
PUT #XFile, 1, AcctFile

Thanks

__________________________________________________
Code tags added
17.07.2017
RSBasic

Re: Read and Write Records

Posted: Sun Jul 16, 2017 6:58 pm
by Mijikai
AcctFile.AcctRecord

WriteData(0,@AcctFile,SizeOf(AcctRecord))

Re: Read and Write Records

Posted: Sun Jul 16, 2017 7:12 pm
by alxfrnds
Mijikai wrote:AcctFile.AcctRecord

WriteData(0,@AcctFile,SizeOf(AcctRecord))
Thanks for the prompt answer,
it looks great for just one record,
but suppose I have 10 records and I want to read and later write record number 5.

How do I do?

Re: Read and Write Records

Posted: Sun Jul 16, 2017 8:21 pm
by Mijikai
alxfrnds wrote:
Mijikai wrote:AcctFile.AcctRecord

WriteData(0,@AcctFile,SizeOf(AcctRecord))
Thanks for the prompt answer,
it looks great for just one record,
but suppose I have 10 records and I want to read and later write record number 5.

How do I do?
...
FileSeek(0,SizeOf(AcctRecord) * 4)
ReadData(0,@AcctFile,SizeOf(AcctRecord))
WriteData(0,@AcctFile,SizeOf(AcctRecord))