News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Making a string array

Started by Devain, September 08, 2010, 02:19:58 AM

Previous topic - Next topic

Devain

So I finally got down to playing with PlayBasic! Started out testing some basic types and operations and ran into a strange thing with the "As String" functionality.

Really, what didn't work was this:
Dim myArray(10) As String

Instead, in order to get the same functionality, I had to do this:

Type myType
    Text As String
EndType

Dim myArray(10) As myType


Is this intentional, or is it something that just isn't completed yet?

I saw in the documentation on types something about all operations not being possible with the "As String" addition, specifically. It said something about PB 1.28.

Of course, this isn't a super-biggie. I just found it odd.

kevin


A string array is declared

Dim MyArray$(Size)

Devain

Well, of course, but I prefer not to use dollar or hash signs. That was why I tried to do it this way, instead.

kevin

 You have to use the # and $ signs.

Devain

But not for variables with a prior declaration, right?

Would a function like this be legal, for example:


Function myFunc( _Value As Integer, _Text As String )
    Print( _Value )
    Print( _Text )
EndFunction

kevin


Devain

Ah! I see. Well, I guess the hash and dollar signs makes code more readable anyway. Just not very used to them.

Makeii Runoru

Those signs are somewhat a staple in BASIC and its derivatives. A lot of newer versions have done away with them, or kept them in the background in case anyone still used them.
This signature is boring, and could be improved. However, the user of this signature doesn't need a fancy signature because he or she doesn't really care for one.

Devain

I used DBP before. If you used the "as String" syntax there, you could do away with the signs. They were more of a default. That's why I expected the same behavior here.

But really, it's actually a syntax helper in the end. I've come to get used to it, by now. I'll hopefully be able to post something in the Showcase board before the end of the year, even though work is getting the better of me...