VBAndCs / sVB-Small-Visual-Basic

Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows OS.
Other
222 stars 16 forks source link

Error Message about Num of Params #13

Closed sjsepan3 closed 1 year ago

sjsepan3 commented 1 year ago

screenshot1a

I was trying to load a Form.ShowMessage with text ~~from an array in Global, but it was balking at Global.AppInfo!FieldName, complaining about the !, even though it recognized the preceding code as an array in Global. So I removed that from the method,~~ and just tried a simple test of the call, but I got this conflicting message (see image) telling me that I needed 3 params even though the intellisense and docs say I need 2.

UPDATE1: (re: strikeout text) I figured out my global array issue -- I read in the docs that property indicator'.' doesn't get along with continuation indicator '_', and realized that the '!' is probably the same. UPDATE2: (nevermind)I figured out this one too -- the formal definition in the docs says Form.ShowMessage, but its (instance) Me.ShowMessage.

sjsepan3 commented 1 year ago

closed for reasons mentioned above

VBAndCs commented 1 year ago

@sjsepan3 The SB compiler doesn't support objects, while sVB seems to do. But in fact, sVB lowers the object-like syntax to a static method call that SB compiler can process. This is done in the sVB.vb class. This is why I prevented splitting the line around . and ! , because it will complicate this lowering process. A static method has an extra first param that receives the object key, so, you can use: Form.ShowMessage(Me, message, "about") or just Me.ShowMessage(message, "about") I had to hide the control classes from the auto completion list, not to confuse kids with such old SB syntax, and this is why the first param doesn't appear in the popup label, as it is not expected to be used. But the book mentions the first param and says you can omit it if you use the instance method. Thanks.