From aa0cd707987a3460e5f74ceda3f96515974cd011 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Mon, 17 Sep 2012 19:11:22 +0200 Subject: fdo#46704 replace wrong example to Noel Power's example Change-Id: Iec4909f84cacf0a9d8d4228a4063287764fa0aa5 --- .../source/text/sbasic/shared/03020202.xhp | 57 +++++++++++++--------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'helpcontent2/source') diff --git a/helpcontent2/source/text/sbasic/shared/03020202.xhp b/helpcontent2/source/text/sbasic/shared/03020202.xhp index 10289a2556..7f8f5c70db 100644 --- a/helpcontent2/source/text/sbasic/shared/03020202.xhp +++ b/helpcontent2/source/text/sbasic/shared/03020202.xhp @@ -60,27 +60,40 @@ Records that are separated by commas cannot be assigned to a string variable. Quotation marks (") in the file are disregarded as well. If you want to read these characters from the file, use the Line Input# statement to read pure text files (files containing only printable characters) line by line. If the end of the file is reached while reading a data element, an error occurs and the process is aborted. Example: -Sub ExampleWorkWithAFile -Dim iNumber As Integer -Dim sLine As String -Dim aFile As String -Dim sMsg as String -aFile = "c:\data.txt" -iNumber = Freefile -Open aFile For Output As #iNumber -Print #iNumber, "This is a line of text" -Print #iNumber, "This is another line of text" -Close #iNumber -iNumber = Freefile -Open aFile For Input As iNumber -While not eof(iNumber) -Line Input #iNumber, sLine -If sLine <>"" then -sMsg = sMsg & sLine & chr(13) -end if -wend -Close #iNumber -Msgbox sMsg -End Sub + +Sub ExampleWorkWithAFile +Dim iCount As Integer +Dim sName As String +Dim sValue As Integer +Dim sFileName as String + +sFileName = "c:\data.txt" +iCount = Freefile + +' Write data ( which we will read later with Input ) to file +Open sFileName for OutPut as iCount +sName = "Hamburg" +sValue = 200 +Write #iCount, sName, sValue +sName = "New York" +sValue = 300 +Write #iCount, sName, sValue +sName = "Miami" +sValue = 459 +Write #iCount, sName, sValue +Close #iCount + +iCount = Freefile +' Read data file using Input +Open sFileName for Input as iCount +Input #iCount; sName, sValue +Msgbox sName & " " & sValue +Input #iCount; sName, sValue +Msgbox sName & " " & sValue +Input #iCount; sName, sValue +Msgbox sName & " " & sValue +Close #iCount +End Sub + -- cgit