String expressions

Questions about the BASICtools and MakeItC
Post Reply
basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

String expressions

Post by basicchip »

>from help line
Armbasic[9.34h]

Welcome to ARMbasic Kernel[7.43] Copyright 2008, Coridium Corp.
for the ARMmite

Programming Flash 2103...

MyString = "My Integer is " & Str(MyInteger) & "mV"
-ERROR C:/Users/Richard/Documents/Coridium/TestSTR.bas: 9: expected comparison operator, found end of line
MyString = "My Integer is " & Str(MyInteger) & "mV"
-ERROR C:/Users/Richard/Documents/Coridium/TestSTR.bas: 9: Expected Operand, found "mV"
MyString = "My Integer is " & Str(MyInteger) & "mV"
-ERROR C:/Users/Richard/Documents/Coridium/TestSTR.bas: 9: expected expression, found & "mV"
MyString = "My Integer is " & Str(MyInteger) & "mV"
-First ERROR at line :9
_______________________________________________________________________________

If you remove the '& "mV' from the concatenation the error disappears and the test program runs correctly

Am I doing something stupid ?



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: String expressions

Post by basicchip »

Astr = "something" & str(x) & "else"

Well you know, you're just doing a case we did not expect in the parser. The use of strings is not consistent across BASICs and is a special case, yes this is a "feature", one that we may look at some time if we are ever mucking with strings in the compiler again (but don't hold your breath). Why? Because there are a bunch of different ways to do the same thing, that the compiler does like

Code: Select all

Astr = "something" & x & "else"       ' in this case the STR(x) is implied

Astr = "something" + str(x)
Astr = "Astr & "else"                 ' just make it 2 statements

Astr = sprintf("something %d else",x)
While these above are all simple expressions. Strings are handled with one string accumulator, so some string expressions would be too complex to handle, as to parse them we would have to "push" the string onto the stack, and we are not going there.

Post Reply