Issue 117960 - Basic: Line Input doesn't work in single-line If
Summary: Basic: Line Input doesn't work in single-line If
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Normal
Target Milestone: 4.2.0
Assignee: AOO issues mailing list
QA Contact: kay.ramme
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2011-04-29 13:59 UTC by dyo
Modified: 2017-05-20 09:31 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.2.0-dev
Developer Difficulty: ---


Attachments
Open Office Basic Macros code (310 bytes, text/plain)
2011-04-29 13:59 UTC, dyo
no flags Details
Hack to restore LINE parsing as a token (539 bytes, patch)
2015-11-24 01:39 UTC, damjan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description dyo 2011-04-29 13:59:42 UTC
Created attachment 76464 [details]
Open Office Basic Macros code 

The following Oracle Open Office Basic line (see code in attachment):

 If Not(EoF(iFic)) Then Line Input #iFic, sRes

give a compilation error in OOO 3.3.0, but not with previous version
for example our production version Staroffice 9.2.

Error:
Syntax Error BASIC
Unexpected Symbol: Input.

Changing to:
If Not(EoF(iFic)) Then
  Line Input #iFic, sRes
End If

is OK, but as we have thousands of subroutines to migrate !
We expected that the macros code is compatible between 3.2 and 3.3 and that we don't need to review all the libraries.

Thank is advance for feedback
Comment 1 Oliver-Rainer Wittmann 2012-06-13 12:31:19 UTC
getting rid of value "enhancement" for field "severity".
For enhancement the field "issue type" shall be used.
Comment 2 damjan 2015-11-24 01:28:19 UTC
This is a regression probably caused by the patch for #92642 (linked to that bug).
Comment 3 damjan 2015-11-24 01:39:54 UTC
Created attachment 85151 [details]
Hack to restore LINE parsing as a token

This patch treats "Line" as a LINE token, not a SYMBOL.

Issue 92642 added the ability to use "Line" (and others) as a variable or object name, something allowed in VBA. In doing so, it seems to have regressed the ability to use "Line Input ..." in a single-line "If". But my patch here will restore that, at the cost of regressing the ability to name variables and objects "Line".

The real solution is to dig deeper and find a way to do both by disambiguating the SYMBOL later.
Comment 4 damjan 2015-11-24 04:06:42 UTC
All of these need to work:

	Line = 123
	MsgBox Line

 	iFic = FreeFile()	
	Open "/tmp/result.txt" For Input As #iFic			
	If Not(EoF(iFic)) Then Line Input #iFic, sRes	
	Line Input #iFic, sRes
	Close #iFic
Comment 5 damjan 2015-11-24 18:58:55 UTC
Fixed it properly in r1716234, resolving fixed.

Commit message with details was:

#i117960# Basic: Line Input doesn't work in single-line If

i92642 added the ability to use certain keywords as variable names (eg. name = 1, line = "hi"),
but also caused a regression where "Line Input" is broken in single-line If statements.
This patch fixes that by allowing Then and Else to also be the start-of-line tokens expected to
immediately preceed the "Line" token in order for that "Line" token to be recognized a keyword instead
of a variable name. Also added FVT spreadsheet tests for "Line" as both a variable name and as "Line Input".