The example Sub ExampleWorkWithAFile does not use the INPUT statement at all.
@Christopher Yeleighton: We are talking about LOCALHELP for BASIC concerning "Input# Statement [Runtime]" At least I can confirm that the example only contains "Line Input #iNumber, sLine", the example under that Heading is identical with the example for "Line Input # Statement [Runtime]". If that is the problem, it's very old, I already see that with OOo 3.1.1
That is the problem indeed. There is no Status OLD, so I set it to NEW instead :-)
@Christopher Yeleighton: NEW means CONFIRMED, so it's OK @David, Noel: Can your please check what the correct example might be? Please set Status to ASSIGNED and add yourself to "Assigned To" if you accept this Bug.
I can provide an example but who can do the right thing with it ;-)
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 now to find out what and where the help for this is under source code control
The git location is in the URL. I modified your code a bit and it does not work: Sub ExampleWorkWithAFile Dim iCount% Dim sName$ Dim dValue# Const sFileName = "/tmp/input.txt" iCount% = Freefile% ' Write data ( which we will read later with Input ) to file open sFileName for OutPut as iCount% sName$ = "Hamburg" dValue# = 200.1 Write #iCount%; sName$, dValue# sName$ = "New York" dValue# = 300.2 Write #iCount%; sName$, dValue# sName$ = "Miami" dValue = 459.3 Write #iCount%; sName$, dValue# close #iCount% ' Read data file using Input open sFileName for Input as iCount% Input #iCount%; sName$, dValue# msgbox sName$ & " " & dValue# ' Hamburg 200,1 Input #iCount%; sName$, dValue# msgbox sName$ & " " & dValue# ' New York 300,2 Input #iCount%; sName, dValue# msgbox sName$ & " " & dValue# ' Miami 459,3 Close #iCount% End Sub I get: Hamburg 200 Error: Bad data on input
(In reply to comment #6) > The git location is in the URL. already found that > > I modified your code a bit and it does not work: did the orig code work ? both versions work for me on Lo3.5 ( linux & windows ) are you trying a more recent version than the 3.3.0 beta this bug was opened against ? > > Hamburg 200 > Error: Bad data on input did you check the contents of input.txt ( '200' for hamburg is wrong ), perhaps the file is corrupt or truncated which might explain the 'Bad data' error for me
Created attachment 57767 [details] input/output file generated from macro might be worth verifying that the input part alone works with this file ( perhaps there is a problem with write statement with the version of Libreoffice you are using ) - don't recall fixing anything to do with that though
(In reply to comment #7) > (In reply to comment #6) > > The git location is in the URL. > already found that > > > > I modified your code a bit and it does not work: > did the orig code work ? Yes, it did. > both versions work for me on Lo3.5 ( linux & windows ) > are you trying a more recent version than the 3.3.0 beta this bug was opened > against ? No, I do not have one. > > > Hamburg 200 > > Error: Bad data on input > did you check the contents of input.txt ( '200' for hamburg is wrong ), perhaps > the file is corrupt or truncated which might explain the 'Bad data' error for > me "Hamburg",200,1 "New York",300,2 "Miami",459,3
(In reply to comment #8) > Created attachment 57767 [details] > input/output file generated from macro > > might be worth verifying that the input part alone works with this file ( > perhaps there is a problem with write statement with the version of Libreoffice > you are using ) - don't recall fixing anything to do with that though Your file gives me: Hamburg 200 New York 300 Miami 459
(In reply to comment #9) > > did you check the contents of input.txt ( '200' for hamburg is wrong ), perhaps > > the file is corrupt or truncated which might explain the 'Bad data' error for > > me > > "Hamburg",200,1 > "New York",300,2 > "Miami",459,3 that ',' is suspicious looks like there is some locale specific separator thing going on. (In reply to comment #10) > > might be worth verifying that the input part alone works with this file ( > > perhaps there is a problem with write statement with the version of Libreoffice > > you are using ) - don't recall fixing anything to do with that though > > Your file gives me: > > Hamburg 200 makes me even more suspicious about what I said above regarding separators, in anycase that imho requires a new bug, this one is about documentation & examples. Could you open a separate bug for this new issue, details of locale and any specific or custom settings relating to that ( e.g. from Tools|Options|Language Settings|Language stuff like Decimal separator etc. ) probably would be very helpful
this issue doesn't in any way depend on or should be blocked by bug #46705
hmm, looking at this further I think the problem described about "200" vrs "200,1" is actually not a bug. Ok, I qualify this by saying not a bug according to the documentation, e.g. help for Input states "A numeric variable is read up to the first carriage return (Asc=13), line feed (Asc=10), space, or comma." help for Write states "Each Write statement outputs a line end symbol as last entry.Numbers with decimal delimiters are converted according to the locale settings." so, I think it behaves as described ( but sucks badly, perhaps always writing '.' would have been a better choice, then Input could convert it in a locale specific way )
Andras Timar committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/help/commit/?id=aa0cd707987a3460e5f74ceda3f96515974cd011 fdo#46704 replace wrong example to Noel Power's example The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
I added Noel's example form Comment 5 to help, so the original bug has been fixed.
(In reply to comment #15) > I added Noel's example form Comment 5 to help, so the original bug has been > fixed. damn, I do recall I had modified the help for this before but I must have not pushed the commit, anyway thanks for finding and fixing