possible bug or design ?

Just starting out? Need help? Post your questions and find answers here.
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

possible bug or design ?

Post 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 ?
User avatar
Demivec
Addict
Addict
Posts: 4281
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: possible bug or design ?

Post 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$
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: possible bug or design ?

Post by mk-soft »

Code: Select all

a=100
Debug "" + a + "% right"
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: possible bug or design ?

Post by moricode »

No Error:

Code: Select all

#         abc        =            $       abc 
#         abc123     =            $       123abc 

abc    +    #         abc  +     #         abc123     +     123      +   $       123abc 
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: possible bug or design ?

Post by moricode »

show Error:

Code: Select all

abc     $    =       "aghf"
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: possible bug or design ?

Post 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.
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: possible bug or design ?

Post 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.
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: possible bug or design ?

Post 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
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: possible bug or design ?

Post by moricode »

No error :

Code: Select all

p    **p


p    *       *P

Error :

Code: Select all

P    *       *    P     ; Error
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: possible bug or design ?

Post 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)

Little John
Addict
Addict
Posts: 4803
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: possible bug or design ?

Post 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.
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: possible bug or design ?

Post 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.
AZJIO
Addict
Addict
Posts: 2224
Joined: Sun May 14, 2017 1:48 am

Re: possible bug or design ?

Post 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.
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: possible bug or design ?

Post 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
Post Reply