Siebel VB Language Reference > Methods Reference for Siebel VB > File Input and Output Methods >

Write Variable to File Method


The Write Variable to File method writes a variable to a file opened in random mode or binary mode. It does not return a value. Usage for this method with random mode and binary mode is the same usage for these modes with the Get File Contents method. For more information, see Usage with Random Mode and Usage with Binary Mode.

The Put statement uses the default character encoding of the local operating system. It does not write to the file in Unicode format.

Format

Put [#]filenumber, [recnumber], varName

The following table describes the arguments that you can use with this method.

Argument
Description

filenumber

The file number that the Open statement uses to open the file. For more information, see Open File Method.

recnumber

An expression of type long. It contains a value that depends on one of the following modes:

  • Random mode. The record number at which to start reading.
  • Binary mode. The byte offset at which to start reading.

The recnumber argument is in the range of 1 through 2,147,483,647. If you do not include this argument, then this method uses the next record or byte.

You must include the commas before and after the recnumber argument even if you do not include the recnumber argument.

varName

The name of the variable that contains the data to write. It can be any variable type except for the following types:

  • Object.
  • Application data.
  • Array. You can use a single array element.
Example

The following example opens a file for random access, puts the values 1 through 10 in this file, prints the contents of the file, and then closes it:

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

Siebel VB Language Reference Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Legal Notices.