home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <html><head><title>Get Statement [Runtime]</title><meta name="filename" content="text/sbasic/common/03020201"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
-
- p.P1{
- }
- span.T1{
- font-weight:bold;}
- </style></head><body>
-
-
- <help:to-be-embedded Eid="get" xmlns:help="http://openoffice.org/2000/help"><a name="get"/>
- <p class="Head1"><help:link Id="66578">Get Statement [Runtime]</help:link></p>
- <p class="Paragraph">Reads a record from a relative file, or a sequence of bytes from a binary file, into a variable.</p>
- </help:to-be-embedded>
- <p class="Paragraph">See also: <help:link Id="66627" Eid="put" xmlns:help="http://openoffice.org/2000/help">PUT</help:link> Statement</p>
- <p class="Paragraph"><span class="T1">Syntax</span>:</p>
- <p class="Paragraph">Get [#] FileNumber As Integer, [Position], Variable <help:key-word value="Get" tag="kw66578_1" xmlns:help="http://openoffice.org/2000/help"/></p>
- <p class="Paragraph"><span class="T1">Parameter</span>:</p>
- <p class="Paragraph">FileNumber: Any integer expression that determines the file number.</p>
- <p class="Paragraph">Position: For files opened in Random mode, <span class="T1">Position</span> is the number of the record to be read.</p>
- <p class="Paragraph">For files opened in Binary mode, <span class="T1">Position</span> is the byte position within the file where reading starts.</p>
- <p class="Paragraph">If <span class="T1">Position</span> is omitted, the current position or the current data record of the file is used.</p>
- <p class="Paragraph">Variable: Name of the variable to be read. With the exception of object variables, any variable type can be used.</p>
- <p class="Paragraph"><span class="T1">Example:</span></p>
- <p class="PropText">Sub ExampleRandomAccess</p>
- <p class="PropText">Dim iNumber As Integer</p>
- <p class="PropText">Dim sText As Variant REM Must be a variant</p>
- <p class="PropText">Dim aFile As String</p>
- <p class="PropText">aFile = "c:\data.txt"</p>
- <p class="PropText"/>
- <p class="PropText">iNumber = Freefile</p>
- <p class="PropText">Open aFile For Random As #iNumber Len=32</p>
- <p class="PropText">Seek #iNumber,1 REM Position at beginning</p>
- <p class="PropText">Put #iNumber,, "This is the first line of text" REM Fill line with text</p>
- <p class="PropText">Put #iNumber,, "This is the second line of text"</p>
- <p class="PropText">Put #iNumber,, "This is the third line of text"</p>
- <p class="PropText">Seek #iNumber,2</p>
- <p class="PropText">Get #iNumber,,sText</p>
- <p class="PropText">Print sText</p>
- <p class="PropText">Close #iNumber</p>
- <p class="PropText"/>
- <p class="PropText">iNumber = Freefile</p>
- <p class="PropText">Open aFile For Random As #iNumber Len=32</p>
- <p class="PropText">Get #iNumber,2,sText</p>
- <p class="PropText">Put #iNumber,,"This is a new text"</p>
- <p class="PropText">Get #iNumber,1,sText</p>
- <p class="PropText">Get #iNumber,2,sText</p>
- <p class="PropText">Put #iNumber,20,"This is the text in record 20"</p>
- <p class="PropText">Print Lof(#iNumber)</p>
- <p class="PropText">Close #iNumber</p>
- <p class="PropText"/>
- <p class="PropText">end sub</p>
- <p class="PropText"/>
- </body></html>