Siebel VB Language Reference > Siebel VB Language Reference >

Put Statement


This standard VB statement writes a variable to a file opened in random or binary mode.

Syntax

Put [#]filenumber, [ recnumber], varName

Argument
Description
filenumber
The file number used in the Open statement to open the file
recnumber
An expression of type long containing the record number or the byte offset at which to start writing
varName
The name of the variable containing the data to write

Returns

Not applicable

Usage

Filenumber is the number assigned to the file when it was opened. For more information, read Open Statement.

Recnumber is in the range 1 to 2,147,483,647. If recnumber is omitted, the next record or byte is written.

NOTE:  The commas before and after recnumber are required, even if no recnumber is specified.

VarName can be any variable type except object, application data type, or array variables (single array elements can be used).

For random mode, the following conditions apply:

Files opened in binary mode behave similarly to those opened in random mode except:

NOTE:  The Put statement uses the default code page of the local operating system. It does not write to the file in Unicode format.

Example

This example opens a file for Random access, puts the values 1 through 10 in it, prints the contents, and closes the file again.

Sub Button_Click
' Put the numbers 1-10 into a file
   Dim x As Integer, y As Integer
   Open "C:\TEMP001" as #1
   For x = 1 to 10
      Put #1,x, x
   Next x
   msgtext = "The contents of the file is:" & Chr(10)
   For x = 1 to 10
      Get #1,x, y
      msgtext = msgtext & y & Chr(10)
   Next x
   Close #1
      Kill "C:\TEMP001"
End Sub

See Also

Close Statement
Get Statement
Open Statement
Write Statement


 Siebel VB Language Reference
 Published: 18 June 2003