Bug 46704 - BASIC LOCALHELP: example for INPUT statement is irrelevant
Summary: BASIC LOCALHELP: example for INPUT statement is irrelevant
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Noel Power
URL: http://cgit.freedesktop.org/libreoffi...
Whiteboard: infoprovider: Christopher Yeleighton ...
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-27 16:22 UTC by Christopher Yeleighton
Modified: 2012-09-18 08:08 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
input/output file generated from macro (47 bytes, text/plain)
2012-02-28 05:41 UTC, Noel Power
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Yeleighton 2012-02-27 16:22:10 UTC
The example Sub ExampleWorkWithAFile does not use the INPUT statement at all.
Comment 1 Rainer Bielefeld Retired 2012-02-27 22:02:03 UTC
@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
Comment 2 Christopher Yeleighton 2012-02-28 00:33:11 UTC
That is the problem indeed.
There is no Status OLD, so I set it to NEW instead :-)
Comment 3 Rainer Bielefeld Retired 2012-02-28 02:13:22 UTC
@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.
Comment 4 Noel Power 2012-02-28 03:13:24 UTC
I can provide an example but who can do the right thing with it ;-)
Comment 5 Noel Power 2012-02-28 03:30:20 UTC
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
Comment 6 Christopher Yeleighton 2012-02-28 05:17:11 UTC
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
Comment 7 Noel Power 2012-02-28 05:38:33 UTC
(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
Comment 8 Noel Power 2012-02-28 05:41:25 UTC
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
Comment 9 Christopher Yeleighton 2012-02-28 07:29:55 UTC
(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
Comment 10 Christopher Yeleighton 2012-02-28 07:34:13 UTC
(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
Comment 11 Noel Power 2012-02-28 08:08:47 UTC

(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
Comment 12 Noel Power 2012-02-29 01:57:01 UTC
this issue doesn't in any way depend on or should be blocked by bug #46705
Comment 13 Noel Power 2012-02-29 02:57:40 UTC
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 )
Comment 14 Not Assigned 2012-09-17 17:10:51 UTC
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.
Comment 15 Andras Timar 2012-09-17 17:12:27 UTC
I added Noel's example form Comment 5 to help, so the original bug has been fixed.
Comment 16 Noel Power 2012-09-18 08:08:11 UTC
(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