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.

์ƒ๋Œ€ ํŒŒ์ผ์— ๋Œ€ํ•œ ์ฐธ๊ณ  ์‚ฌํ•ญ: ์ด ๋ณ€์ˆ˜์˜ ๋‚ด์šฉ์ด Open ๋ฌธ์˜ Len ์ ˆ์— ์ง€์ •๋œ ๋ ˆ์ฝ”๋“œ ๊ธธ์ด์™€ ์ผ์น˜ํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ์ƒˆ๋กœ ๊ธฐ๋ก๋œ ๋ ˆ์ฝ”๋“œ์˜ ๋ ๋ถ€๋ถ„๊ณผ ๋‹ค์Œ ๋ ˆ์ฝ”๋“œ ์‚ฌ์ด์˜ ๊ณต๋ฐฑ์ด ์“ฐ๋ ค๋Š” ํŒŒ์ผ์˜ ๊ธฐ์กด ๋ฐ์ดํ„ฐ๋กœ ์ฑ„์›Œ์ง‘๋‹ˆ๋‹ค.

์ด์ง„ ํŒŒ์ผ์— ๋Œ€ํ•œ ์ฐธ๊ณ  ์‚ฌํ•ญ: ๋ณ€์ˆ˜ ๋‚ด์šฉ์ด ์ง€์ •ํ•œ ์œ„์น˜์— ๊ธฐ๋ก๋˜๊ณ  ๋งˆ์ง€๋ง‰ ๋ฐ”์ดํŠธ์˜ ๋ฐ”๋กœ ๋’ค์— ํŒŒ์ผ ํฌ์ธํ„ฐ๊ฐ€ ์‚ฝ์ž…๋ฉ๋‹ˆ๋‹ค. ๋ ˆ์ฝ”๋“œ ๊ฐ„์— ๊ณต๋ฐฑ์ด ๋‚จ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

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,, "ํ…์ŠคํŠธ์˜ ์ฒซ ํ–‰์ž…๋‹ˆ๋‹ค." 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!