AFTERLAST$ doesn't work when concatenated

Discussions about the Liberty BASIC language, with particular reference to LB Booster
Tasp
Posts: 16
Joined: Sun May 31, 2020 4:51 pm

AFTERLAST$ doesn't work when concatenated

Post by Tasp »

LBB refuses to handle the following. But LB does.

Am I missing something obvious or do I need to break this up to use LBB?

Code: Select all

DIM config(20)

config$(0) = "= 120"
config$(1) = "= 120"
config$(2) = "= 120"
config$(3) = "= 120"
config$(4) = "= 120"
config$(5) = "= 120"
config$(6) = "= 120"
config$(7) = "= 120"
config$(8) = "= 120"
config$(9) = "= 120"
config$(10) = "= 120"


    AudioEnabled =  VAL(TRIM$(AFTERLAST$(config$(0), "=")))
    AudioConstant = VAL(TRIM$(AFTERLAST$(config$(1), "=")))
    SpeechEnabled = VAL(TRIM$(AFTERLAST$(config$(2), "=")))
    port$ =             TRIM$(AFTERLAST$(config$(3), "="))
    bufLen =        VAL(TRIM$(AFTERLAST$(config$(4), "=")))
    loglvl =        VAL(TRIM$(AFTERLAST$(config$(5), "=")))
    WavEnabled =    VAL(TRIM$(AFTERLAST$(config$(6), "=")))
    BeepEnabled =   VAL(TRIM$(AFTERLAST$(config$(7), "=")))
    AlarmWavFilename$ =(TRIM$(AFTERLAST$(config$(8), "=")))
    MWULX =         VAL(TRIM$(AFTERLAST$(config$(9), "=")))
    MWULY =         VAL(TRIM$(AFTERLAST$(config$(10), "=")))
    MWWW =          VAL(TRIM$(AFTERLAST$(config$(11), "=")))
    MWWH =          VAL(TRIM$(AFTERLAST$(config$(12), "=")))
    AHULX =         VAL(TRIM$(AFTERLAST$(config$(13), "=")))
    AHULY =         VAL(TRIM$(AFTERLAST$(config$(14), "=")))
    LVW =           VAL(TRIM$(AFTERLAST$(config$(15), "=")))
    LVH =           VAL(TRIM$(AFTERLAST$(config$(16), "=")))
    

'include lb45func.bas
Nope, it doesn't like AFTERLAST$ like this either

Code: Select all

string$ = "test = value"

value$ = AFTERLAST$(string$, "=")

print value$ 

'include lb45func.bas
guest
Site Admin
Posts: 192
Joined: Tue Apr 03, 2018 1:34 pm

Re: AFTERLAST$ doesn't work when concatenated

Post by guest »

Tasp wrote: Mon Jun 01, 2020 6:13 pmAm I missing something obvious or do I need to break this up to use LBB?
The most obvious fault is that you are using AFTERLAST$ rather than afterlast$. The LBB documentation states, in the Liberty BASIC 4.5.0 section: "Note that the function names must be specified in lower-case". This is inevitably the case (!) because the new LB 4.5 functions are implemented in LBB as user-defined functions in the lb45func.bas library, and of course user-defined functions have case-sensitive names whereas built-in functions don't.

So this works as expected for me:

Code: Select all

string$ = "test = value"

value$ = afterlast$(string$, "=")

print value$ 

'include lb45func.bas
Tasp
Posts: 16
Joined: Sun May 31, 2020 4:51 pm

Re: AFTERLAST$ doesn't work when concatenated

Post by Tasp »

Ah, that makes total sense now you point it out!

Since I always capitalise all my commands (From Spectrum and BBC days of programming), it didn't occur to me that it was using it as a function despite looking at the lb45func.bas code.

Thanks for the simple fix!