Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Write data record into a file open AS RANDOM

 

Syntax

 

n = FILE_PUTR(FileID, nRec, UDTStructure)

 

Returns

 

Number, error code.

 

Parameters

 

Name

Type

Optional

Meaning

FileID

Number

No

A previously open random access file handle

nRec

Number

No

Record number to be stored

UDTStructre

UDT

No

Any UDT data structure. Use the same UDT to GET data from and PUT into a random access file.

 

Remarks

 

Restrictions

 

See also

 

File_GETR

 

Examples

 

Thanks to Psch for the following script example

USES "File""Console"

 

Type tRecord

  LName As String * 12

  FName As String * 8

  Age   As Byte

End Type

 

Dim Item        As tRecord

Dim OutFileName As String = app_sourcepath & "Test.DAT"

Dim f           As DWORD

 

file_KILL(OutFileName)

f = file_Open(OutFileName, "random"SIZEOF(tRecord))

 

PRINTL "Vader in the file"

  Item.LName = "Vader"

  Item.FName = "Darth"

  Item.Age   = 40

  file_putr(f, 1, Item)

 

PRINTL "Yoda in the file"

  Item.LName = "Yoda"

  Item.FName = "Mister"

  Item.Age   = 45

  file_putr(f, 2, Item)

 

PRINTL "---------------------------"

 

PRINTL "Seeking first: "

  file_getr(f, 1, Item)

  PRINTL item.LName, item.FName, item.Age

 

PRINTL "Seeking second: "

  file_getr(f, 2, Item)

  PRINTL item.LName, item.FName, item.Age

 

file_Close(f)

 

WAITKEY

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software