LB Booster
« LB parses "DATA" word in string »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:29am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: LB parses "DATA" word in string  (Read 277 times)
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx LB parses "DATA" word in string
« Thread started on: Jul 20th, 2017, 7:04pm »

Hi,

I've just made a program called LOGIDATA.

But, it looks like LBB is parsing the DATA statement contained in texts like in a NOTICE. This won't happen when I use LB.

This code will work:
Code:
[ABOUT]
   NOTICE "About..."+CHR$(13)+"LOGICData"
   WAIT 


This code will generate errors messages or stop the program due to memory errors:
Code:
[ABOUT]
   NOTICE " About..."+CHR$(13)+"LOGICDATA"
   WAIT 


The only difference between both codes is the case of the word "LOGICDATA".

When it is written all uppercase, problems arise (error messages "string too long", "no room"). Writing this word "LOGICData" will cause no trouble.

Is my observation correct?
« Last Edit: Jul 20th, 2017, 7:08pm by flotulopex » User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LB parses "DATA" word in string
« Reply #1 on: Jul 20th, 2017, 7:57pm »

on Jul 20th, 2017, 7:04pm, flotulopex wrote:
Is my observation correct?

I can't detect anything wrong. This code works correctly, as far as I can tell:

Code:
   NOTICE " About..."+CHR$(13)+"LOGICDATA" 

If you believe there is a problem, please list a complete (but preferably short) program which illustrates it.

Richard.
User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx Re: LB parses "DATA" word in string
« Reply #2 on: Jul 20th, 2017, 8:39pm »

When I compile this code with LB AND the word "LOGICDATA" is written once, all uppercase, anywhere in the code, I'll systematically get an error message like this http://home.citycable.ch/flotulopex/LBB/2017-07-20-ConTEXT%20-%20%5bD__LibertyBASIC_LOGICDATA%20Table%20Controller_LOGICDATA_Table.bas%5d.jpg

Well, this is the code:
Code:
' "LOGICData Table Controller"

PrgVersion$ = "0-0-1-1"

ComPort = 0
TableHeight  = 0
TableHeight$ = ""
LOGICData$   = "" ' LOGICData protocol
ComOpen      = 0  ' keeps track of opened Com Port
CS           = 0  ' CheckSum
CR$          = CHR$(13) ' "Carriage Return"
LFCR$        = CHR$(10)+CHR$(13) ' "Line Feed & Carriage Return"

NOMAINWIN

ONCOMERROR [ComErrorHandler]

[MAIN]
   WindowWidth  = 213
   WindowHeight = 300
   UpperLeftX   = INT((DisplayWidth-WindowWidth)/2)
   UpperLeftY   = INT((DisplayHeight-WindowHeight)/2)

'   MENU #Main, "&File", "E&xit",[QUIT]
'   MENU #Main, "&?","&About...",[ABOUT]

   ' " Table Height "
   GROUPBOX   #Main.GBx10," Table Height ",              10, 10,185,115
   TEXTBOX    #Main.TBx10,                               30, 30, 30, 20
   STATICTEXT #Main.STx10,"(0..255)",                    65, 33, 80, 20
   STATICTEXT #Main.STx11,"Message sent: "+LOGICData$,   30, 95,160, 20
   BUTTON     #Main.Btn10,"Set",   [SendHeight],     UL, 30, 60, 60, 22
   BUTTON     #Main.Btn11,"Top",   [SendTableTop],   UL,115, 30, 60, 22
   BUTTON     #Main.Btn12,"Bottom",[SendTableBottom],UL,115, 60, 60, 22

   ' " Com Port "
   GROUPBOX   #Main.GBx20," Com Port ",                  10,150,185, 55
   TEXTBOX    #Main.TBx21,                               30,170, 20, 20
   STATICTEXT #Main.STx21,"=",                           52,173, 10, 20
   GRAPHICBOX #Main.GFx21,                               62,173, 15, 15
    'STYLEBITS #Main.GFx21,0,_WS_BORDER,0,0 'remove image's border
   BUTTON     #Main.Btn23,"Ok",[ComOpenPort],UL,        115,170, 60, 22

   ' " EXIT & About "
   BUTTON     #Main.Btn30,"&Exit",[QUIT],UL,            115,230, 60, 22
   BUTTON     #Main.Btn31,"About",[ABOUT],UL,            30,230, 60, 22

   OPEN "LOGICData" FOR window AS #Main
   #Main "TRAPCLOSE [QUIT]"
   #Main.GFx21, "down; fill red; flush"
   IF ComPort <> 0 THEN [ComOpenPort]
   IF ComPort = 0 THEN #Main.TBx21, "!setfocus"
   WAIT

[ComOpenPort]
   IF ComOpen = 0 THEN
      ComOpen = 1
      #Main.TBx21, "!contents? ComPort" ' get the com port #
      #Main.TBx10, "!setfocus"
      OPEN "com";ComPort;":115200,n,8,1" FOR random AS #ComHandle 'LBB syntax
      #Main.TBx21, STR$(ComPort)
      #Main.GFx21, "down; fill green; flush"
   END IF
   WAIT

[ComErrorHandler]
   NOTICE "Serial port error" + CR$ + "Com Port " + STR$(ComPort) + " not found"
   #Main.GFx21, "down; fill red; flush"
   #Main.TBx21, ""
   #Main.TBx21, "!setfocus"
   CLOSE #ComHandle
   ComOpen = 0
   WAIT

[SendTableTop]
   IF ComOpen = 1 THEN ' do it ONLY if com port is open
      'TableHeight = 255/0xFF
      #Main.GBx10," Table Height = 255 "
      #Main.TBx10, ""
      #Main.STx11,"Message sent: 94 10 00 FF 7B"
      #ComHandle "94 10 00 FF 7B" + LFCR$ ' Tisch auf Höhe 255
   END IF
   WAIT

[SendTableBottom]
   IF ComOpen = 1 THEN  ' do it ONLY if com port is open
      'TableHeight = 0/0x00
      #Main.GBx10," Table Height = 0 "
      #Main.TBx10, ""
      #Main.STx11,"Message sent: 94 10 00 00 84"
      #ComHandle "94 10 00 00 84" + LFCR$ ' Tisch auf Höhe 0
   END IF
   WAIT

[SendHeight] 'If height 20(Ox14 or &H14) = "94 10 00 14 90"
   IF ComOpen = 1 THEN ' do it ONLY if com port is open
      #Main.TBx10, "!contents? TableHeight$" ' use string to see if empty
      IF  TableHeight$ = "" THEN [DONOTHING] ' trap a case where the input is empty
      TableHeight = VAL(TableHeight$)        ' since not empty, convert to value and go on
      IF TableHeight < 256 THEN ' do it only if value is 0..255
         #Main.GBx10," Table Height = " + STR$(TableHeight)+ " "
         #Main.TBx10, ""
         CS = &H94 XOR &H10 XOR &H00 XOR TableHeight ' CheckSum calculation
         IF TableHeight < 10 THEN ' adjust i.e "5" to "05"
            LOGICData$ = "94 10 00 0" + DECHEX$(TableHeight) + " " + DECHEX$(CS)
         ELSE
            LOGICData$ = "94 10 00 " + DECHEX$(TableHeight) + " " + DECHEX$(CS)
         END IF
         #Main.STx11,"Message sent: "+LOGICData$
         #ComHandle, LOGICData$ + LFCR$
      ELSE
         [DONOTHING]
         TableHeight = 0
         #Main.GBx10," Table Height "
         #Main.TBx10, ""
         #Main.TBx10, "!setfocus"
         #Main.STx11,"Message sent: "
      END IF
   END IF
   WAIT

[ABOUT]
    NOTICE " About..."+CR$+_
    "LOGICData Table Controller"+CR$+CR$+_
    "         version "+PrgVersion$+CR$+CR$+_
    "Flotulopex & Co. - July 2017"+CR$+CR$+_
    "       Liberty BASIC 4.5.1"+CR$+_
    "      and LB Booster 3.0.8"+CR$+CR$+_
    "       Serial com settings:"+CR$+_
    "            115200,n,8,1"
    WAIT

[QUIT]
   IF ComOpen = 1 THEN CLOSE #ComHandle
   CLOSE #Main
   END 
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LB parses "DATA" word in string
« Reply #3 on: Jul 20th, 2017, 9:20pm »

on Jul 20th, 2017, 8:39pm, flotulopex wrote:
When I compile this code with LB AND the word "LOGICDATA" is written once, all uppercase, anywhere in the code, I'll systematically get an error message like this

The "Line too long" message is most likely indicating exactly that, i.e. that LBB is unhappy with the length of the line here (once all joined together):

Code:
    NOTICE " About..."+CR$+_
    "LOGICDATA Table Controller"+CR$+CR$+_
    "         version "+PrgVersion$+CR$+CR$+_
    "Flotulopex & Co. - July 2017"+CR$+CR$+_
    "       Liberty BASIC 4.5.1"+CR$+_
    "      and LB Booster 3.0.8"+CR$+CR$+_
    "       Serial com settings:"+CR$+_
    "            115200,n,8,1" 

My suggestion would be to split it into shorter segments, for example like this:

Code:
    product$ = "LOGICDATA Table Controller"+CR$+CR$+_
    "         version "+PrgVersion$+CR$+CR$+_
    "Flotulopex & Co. - July 2017"+CR$+CR$
    compiler$ = "       Liberty BASIC 4.5.1"+CR$+_
    "      and LB Booster 3.0.8"+CR$+CR$
    serial$ = "       Serial com settings:"+CR$+_
    "            115200,n,8,1"
    NOTICE " About..."+CR$+product$+compiler$+serial$
 

Arguably this code is clearer, as well as fixing the problem.

Richard.
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: LB parses "DATA" word in string
« Reply #4 on: Jul 20th, 2017, 9:50pm »

Quote:
The "Line too long" message is most likely indicating exactly that, i.e. that LBB is unhappy with the length of the line here (once all joined together):

If I change "LOGICDATA" to "LOGICDATAz", making it longer, error didn't show

If I make it shorter just to "DATA" error shows.

Might it be indeed that it is DATA limit, like posted here?
'Line too long' error

EDIT part that works after DATA 150 characters. 158 works, more fails
EDIT2 test shows limit for ordinary DATA is 248
Code:
    NOTICE _
    "DATA "+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"
'adding another line produces Line too long    

'now I add two lines     and change DATA to TADA
'it works no problem
    NOTICE _
    "TADA "+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789"+_
    "0123456789" 
« Last Edit: Jul 20th, 2017, 9:57pm by tsh73 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LB parses "DATA" word in string
« Reply #5 on: Jul 20th, 2017, 10:13pm »

on Jul 20th, 2017, 9:50pm, tsh73 wrote:
If I change "LOGICDATA" to "LOGICDATAz", making it longer, error didn't show

Hardly a practical solution for the OP though! My suggestion of splitting the long string into shorter segments is effective, so that's the method I recommend he uses to resolve the problem.

BBC BASIC (into which LBB translates the program) has a maximum line length of about 250 characters so I expect the error arises as a result of that limit. Because of my familiarity with that dialect I prefer not to use very long lines. See also the old thread to which Anatoly links.

I think a similar issue can arise if you load a tokenized (.TKN) program into LBB. When LB generates the TKN file I believe it concatenates any 'continuation' lines (ending in an underscore) so you can end up with a line which is too long for the LBB editor.

Richard.
« Last Edit: Jul 20th, 2017, 10:23pm by Richard Russell » User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: LB parses "DATA" word in string
« Reply #6 on: Jul 20th, 2017, 10:42pm »

Your solution , well, solves problem

But interesting thing is - what's going on?

Obviously it's compile-time error

Print is affected too
without concatenation, it takes more characters, (for Notice too) but it breaks if word DATA is present:

Code:
print "DATA 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
 


If I move sequence "DATA " in the middle of a string, it errors too.

If we add a letter after DATA (making string longer) it works
Code:
print "DATAz 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
 


And it errors only if word DATA all uppercase.
« Last Edit: Jul 20th, 2017, 10:45pm by tsh73 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: LB parses "DATA" word in string
« Reply #7 on: Jul 20th, 2017, 11:19pm »

on Jul 20th, 2017, 10:42pm, tsh73 wrote:
But interesting thing is - what's going on?

The answer to that can be found in the earlier thread to which you linked. There it says this: "There may be other obscure situations in which it can arise, but again only if the line is very long". This is evidently one of those "obscure situations".

What matters is how best this issue can be resolved to the satisfaction of the OP who encountered it. I have offered an effective solution, which in my opinion improves the readability of the program as well.

I could, in principle, try to trace in the code of LBB exactly what is happening, but what would be the point? The simple fact is that LBB translates the program to BBC BASIC, and BBC BASIC has a maximum line length limit of about 250 characters. In the particular circumstances of the OP's code, this limit is being hit.

Richard.
User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx Re: LB parses "DATA" word in string
« Reply #8 on: Jul 21st, 2017, 12:13am »

on Jul 20th, 2017, 10:13pm, Richard Russell wrote:
When LB generates the TKN file I believe it concatenates any 'continuation' lines (ending in an underscore)

Yes, I can confirm it does.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls