Put# Statement

αžŸαžšαžŸαŸαžšβ€‹αž€αŸ†αžŽαžαŸ‹β€‹αžαŸ’αžšαžΆβ€‹αž˜αž½αž™β€‹αž‘αŸ…β€‹αž―αž€αžŸαžΆαžšβ€‹αž”αŸ’αžšαŸ‚αž”αŸ’αžšαž½αž› αž¬β€‹αž˜αž½αž™β€‹αž”αŸƒβ€‹αžβ€‹αŸ—β€‹αž‚αŸ’αž“αžΆ αž‘αŸ…β€‹αž―αž€αžŸαžΆαžšβ€‹αž‚αŸ„αž›β€‹αž–αžΈαžšΒ αŸ”

tip

Use Print# statement to print data to a sequential text file. Use Write# statement to write data to a sequential text file with delimiting characters.


Syntax:

Put Statement diagram


Put [#]fileNum, [recordNum|filePos], variable

Parameters:

fileNum: Any integer expression that defines the file that you want to write to.

recordNum, filePos: For relative files (random access files), the number of the record that you want to write.

αžŸαž˜αŸ’αžšαžΆαž”αŸ‹β€‹αž―αž€αžŸαžΆαžšβ€‹αž‚αŸ„αž›β€‹αž–αžΈαžš (αž…αžΌαž›β€‹αžŠαŸ†αžŽαžΎαžšβ€‹αž€αžΆαžšβ€‹αž‚αŸ„αž›β€‹αž–αžΈαžš) αž‘αžΈαžαžΆαŸ†αž„β€‹αž“αŸƒβ€‹αž”αŸƒβ€‹αž€αŸ’αž“αž»αž„β€‹αž―αž€αžŸαžΆαžš αžŠαŸ‚αž›β€‹αž’αŸ’αž“αž€β€‹αž…αž„αŸ‹β€‹αž…αžΆαž”αŸ‹αž•αŸ’αžαžΎαž˜β€‹αžŸαžšαžŸαŸαžšΒ αŸ”

variable: Name of the variable that you want to write to the file.

αž…αŸ†αžŽαžΆαŸ†β€‹αžŸαž˜αŸ’αžšαžΆαž”αŸ‹β€‹αž―αž€αžŸαžΆαžšβ€‹αž”αŸ’αžšαŸ‚αž”αŸ’αžšαž½αž› αŸ– αž”αŸ’αžšαžŸαž·αž“β€‹αž”αžΎβ€‹αž˜αžΆαžαž·αž€αžΆβ€‹αž“αŸƒβ€‹αž’αžαŸαžšβ€‹αž“αŸαŸ‡β€‹αž˜αž·αž“β€‹αž•αŸ’αž‚αžΌαž•αŸ’αž‚αž„β€‹αž”αŸ’αžšαžœαŸ‚αž„β€‹αž“αŸƒβ€‹αž€αŸ†αžŽαžαŸ‹β€‹αžαŸ’αžšαžΆ αžŠαŸ‚αž›β€‹αžαŸ’αžšαžΌαžœβ€‹αž”αžΆαž“β€‹αž”αž‰αŸ’αž‡αžΆαž€αŸ‹β€‹αž€αŸ’αž“αž»αž„β€‹αž’αž“αž»β€‹αž”αŸ’αžšαž™αŸ„αž‚ Len αž“αŸƒβ€‹αžŸαŸαž…αž€αŸ’αžαžΈβ€‹αžαŸ’αž›αŸ‚αž„β€‹αž€αžΆαžšβ€‹ Open αžŠαž€β€‹αžƒαŸ’αž›αžΆβ€‹αž…αž“αŸ’αž›αŸ„αŸ‡β€‹αž…αž»αž„β€‹αž“αŸƒβ€‹αž€αŸ†αžŽαžαŸ‹β€‹αžαŸ’αžšαžΆβ€‹αžŠαŸ‚αž›β€‹αž”αžΆαž“β€‹αžŸαžšαžŸαŸαžšβ€‹αžαŸ’αž˜αžΈ αž“αž·αž„β€‹αž€αŸ†αžŽαžαŸ‹β€‹αžαŸ’αžšαžΆβ€‹αž”αž“αŸ’αž‘αžΆαž”αŸ‹β€‹αžαŸ’αžšαžΌαžœβ€‹αž”αžΆαž“β€‹αž–αž„αŸ’αžšαžΈαž€β€‹αž²αŸ’αž™β€‹αžœαŸ‚αž„β€‹αž‡αžΆαž˜αž½αž™β€‹αž‘αž·αž“αŸ’αž“αž“αŸαž™β€‹αžŠαŸ‚αž›β€‹αž˜αžΆαž“β€‹αžŸαŸ’αžšαžΆαž”αŸ‹β€‹αž–αžΈβ€‹αž―αž€αžŸαžΆαžš αžŠαŸ‚αž›β€‹αž’αŸ’αž“αž€β€‹αž€αŸ†αž–αž»αž„β€‹αžŸαžšαžŸαŸαžšβ€‹αž‘αŸ…Β αŸ”

αž…αŸ†αžŽαžΆαŸ†β€‹αžŸαž˜αŸ’αžšαžΆαž”αŸ‹β€‹αž―αž€αžŸαžΆαžšβ€‹αž‚αŸ„αž›β€‹αž–αžΈαžš αŸ– αž˜αžΆαžαž·αž€αžΆβ€‹αž“αŸƒβ€‹αž’αžαŸαžšβ€‹αžαŸ’αžšαžΌαžœβ€‹αž”αžΆαž“β€‹αžŸαžšαžŸαŸαžšβ€‹αž‘αŸ…β€‹αž‘αžΈαžαžΆαŸ†αž„β€‹αžŠαŸ‚αž›β€‹αž”αžΆαž“β€‹αž”αž‰αŸ’αž‡αžΆαž€αŸ‹β€‹ αž“αž·αž„β€‹αž‘αŸ’αžšαž“αž·αž…β€‹αž―αž€αžŸαžΆαžšβ€‹αžαŸ’αžšαžΌαžœβ€‹αž”αžΆαž“β€‹αž”αž‰αŸ’αž…αžΌαž›β€‹αžŠαŸ„αž™β€‹αž•αŸ’αž‘αžΆαž›αŸ‹β€‹αž”αž“αŸ’αž‘αžΆαž”αŸ‹β€‹αž–αžΈβ€‹αž”αŸƒβ€‹αž…αž»αž„β€‹αž€αŸ’αžšαŸ„αž™Β αŸ” αž‚αŸ’αž˜αžΆαž“β€‹αžŠαž€β€‹αžƒαŸ’αž›αžΆβ€‹αž“αŸ…β€‹αžŸαž›αŸ‹β€‹αžšαžœαžΆαž„β€‹αž€αŸ†αžŽαžαŸ‹β€‹αžαŸ’αžšαžΆΒ αŸ”

Example:

Example:


Sub ExampleRandomAccess
    Dim iNumber As Integer
    Dim sText As Variant REM Must be a variant
    Dim aFile As String
    aFile = "c:\data.txt"
    iNumber = Freefile
    Open aFile For Random As #iNumber Len=32
    Seek #iNumber,1 REM Position at beginning
    Put #iNumber,, "This is the first line of text" REM Fill line with text
    Put #iNumber,, "This is the second line of text"
    Put #iNumber,, "This is the third line of text"
    Seek #iNumber,2
    Get #iNumber,,sText
    Print sText
    Close #iNumber
    iNumber = Freefile
    Open aFile For Random As #iNumber Len=32
    Get #iNumber,2,sText
    Put #iNumber,,"This is a new text"
    Get #iNumber,1,sText
    Get #iNumber,2,sText
    Put #iNumber,20,"This is the text in record 20"
    Print Lof(#iNumber)
    Close #iNumber
End Sub

Please support us!