Page 1 of 1

possible bug or design ?

Posted: Tue Jan 21, 2025 5:07 am
by moricode
pb 5.72

No Error:

Code: Select all

b=456
A$="ERROR Line "+ b + " : [] () Mismatch "
Debug A$
show syntax Error:

Code: Select all

b=456
A$=b + "ERROR Line "+ b + " : [] () Mismatch "
Debug A$


so ?

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 7:22 am
by Demivec
In the help manual under the topic of "Variables, Types and Operators" there is a description next to the '+' operator which reads:
With strings the '+' is also valid for combining the contents of two strings, where the result will be assigned to the string on the LHS with the '=' operator or will be directly stored into the string on the LHS. Numeric values are also accepted for combination with a string. It will behave like using Str(), Str() or StrD() with their defaults for the optional parameters
The string must come first before the concatenation operator for the number to not need Str(), Str() or StrD().

Code: Select all

;The following are all equivalent
V = 345
A$ = " Value = "
B$ = A$ + Str(V)
B$ = A$ + V
B$ = A$ + 345
Debug B$

; The following is not allowed because a string has to come first:
; B$ = V + A$;

;It can be written as follows:
B$ = Str(V) + A$
;or alternatively as
B$ = "" + V + A$
Debug B$

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 9:21 am
by mk-soft

Code: Select all

a=100
Debug "" + a + "% right"

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 9:40 am
by moricode
No Error:

Code: Select all

#         abc        =            $       abc 
#         abc123     =            $       123abc 

abc    +    #         abc  +     #         abc123     +     123      +   $       123abc 

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 10:11 am
by moricode
show Error:

Code: Select all

abc     $    =       "aghf"

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 10:14 am
by #NULL
moricode wrote: Tue Jan 21, 2025 9:40 amNo Error:
That's because in this case, there are no strings involved at all.
abc is not previously declared, so becomes implicit integer, then come 2 numerical constants #abc and #abc123, then decimal number 123 and then hex number $123abc, so no strings involved.

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 10:20 am
by #NULL
moricode wrote: Tue Jan 21, 2025 10:11 amshow Error:
The $ is part of the string variable name, you can't put spaces within the identifier name, and there is no other valid way PB could interpret this. In some case like constants it might just work but is not defined or supported by the language.

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 10:24 am
by moricode
#NULL wrote: Tue Jan 21, 2025 10:20 am
moricode wrote: Tue Jan 21, 2025 10:11 amshow Error:
The $ is part of the string variable name, you can't put spaces within the identifier name, and there is no other valid way PB could interpret this. In some case like constants it might just work but is not defined or supported by the language.
so the space should not allow at all , or it will come to confuse if write code like that

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 10:35 am
by moricode
No error :

Code: Select all

p    **p


p    *       *P

Error :

Code: Select all

P    *       *    P     ; Error

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 11:54 am
by moricode
all no error:

Code: Select all

Debug Bool(a    <          >    b)
Debug Bool(a    >          =    b)
Debug Bool(a    =          <    b)
Debug Bool(a    >          >    b)
Debug Bool(a    <          <    b)


Re: possible bug or design ?

Posted: Tue Jan 21, 2025 4:32 pm
by Little John
moricode wrote: Tue Jan 21, 2025 10:35 am No error :

Code: Select all

p    **p


p    *       *P

Error :

Code: Select all

P    *       *    P     ; Error
So what?
p is an integer variable, *p is a pointer variable.
p **p ist the product of those variables, and so is p * *P.
P * * P is invalid syntax, because two consecutive multiplication signs are not allowed.

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 4:37 pm
by Fred
moricode wrote: Tue Jan 21, 2025 11:54 am all no error:

Code: Select all

Debug Bool(a    <          >    b)
Debug Bool(a    >          =    b)
Debug Bool(a    =          <    b)
Debug Bool(a    >          >    b)
Debug Bool(a    <          <    b)

I agree than operands shouldn't be allowed with space when it's a 2 chars operand.

Re: possible bug or design ?

Posted: Tue Jan 21, 2025 10:20 pm
by AZJIO
moricode
In all cases, you are not creating an incorrect interpretation of the code. It is better to have a separate program for correcting artificially invented errors than to build this into the compiler.

Re: possible bug or design ?

Posted: Wed Jan 22, 2025 3:00 am
by moricode
Little John wrote: Tue Jan 21, 2025 4:32 pm
moricode wrote: Tue Jan 21, 2025 10:35 am No error :

Code: Select all

p    **p


p    *       *P

Error :

Code: Select all

P    *       *    P     ; Error
So what?
p is an integer variable, *p is a pointer variable.
p **p ist the product of those variables, and so is p * *P.
P * * P is invalid syntax, because two consecutive multiplication signs are not allowed.
oh yes, you are right , i agree with you , this is a good example to show you that , all previous post example should remove space and not allow extra space in the between , so it remain language consistency and readability, and reduce human errors .

i bet you already see this and never do some mistake on coding , good luck .


Thanks guy