Structure problems...

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Amiga5k.

Ok, I'm not really a beginner at basic...just at Purebasic

Anyway, I'll be darned if I can figure out what I'm doing wrong here:

Code: Select all

Structure ModStructure
   ModName.s      ; Name of the mod (internal) Max 20 characters
   ModSize.l      ; File\memory size
   Channels.b     ; 4,6 or 8
EndStructure
PBMod.ModStructure\ModName.s = "blahblah"
I get the odd "garbage to end of the line" error message (whatever that means! :)). Is there a way to initialize a new type that isn't mentioned? I even tried Dim'ming the PBMod type but got the same error.

In BB, they must be 'created' first:

Code: Select all

Type ModStructure
    Field Name$
    Field Size
    Field Channels
End Type

BBMod.ModStructure = New ModStructure
BBMod\Name$ = "blahblah"
Anyone know why I'm getting this error?

Thanks
Russell

***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Amiga5k.

Just wanted to point out that the actual Structure has many more elements than I'm showing here for simplicity.

Russell

***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.
Originally posted by Amiga5k

Ok, I'm not really a beginner at basic...just at Purebasic

Anyway, I'll be darned if I can figure out what I'm doing wrong here:

Code: Select all

Structure ModStructure
   ModName.s      ; Name of the mod (internal) Max 20 characters
   ModSize.l      ; File\memory size
   Channels.b     ; 4,6 or 8
EndStructure
PBMod.ModStructure\ModName.s = "blahblah"
write:

Code: Select all

Structure ModStructure
   ModName.s      ; Name of the mod (internal) Max 20 characters
   ModSize.l      ; File\memory size
   Channels.b     ; 4,6 or 8
EndStructure
PBMod.ModStructure
PBMod\ModName = "blahblah"


Its a long way to the top if you wanna .....CodeGuru
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Saboteur.

I only remove the type in the sentence... and it works, I'll read the manual again :)

Code: Select all

Structure ModStructure
   ModName.s      ; Name of the mod (internal) Max 20 characters
   ModSize.l      ; File\memory size
   Channels.b     ; 4,6 or 8
EndStructure

PBMod.ModStructure\ModName="blahblah"  ; <--- ModName without type

Debug PBMod\ModName

Win98 Athlon 1200 256DDR ATI RADEON 9000
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Amiga5k.

Whew! Thanks, guys, I knew it was something simple :) (I guess I know what the 'garbage to the end of line' means now - the '.s'. Although a message such as 'Unnecessary type attachment on Structure element' or something would be easier to understand...

And speaking of type suffixes, once I declare a variable as, say '.w', can I now refer to that variable without the '.w'? (I guess I could try it and see, eh? :))

Thanks again,
Russell

***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Saboteur.
Originally posted by Amiga5k
And speaking of type suffixes, once I declare a variable as, say '.w', can I now refer to that variable without the '.w'? (I guess I could try it and see, eh? :))

Thanks again,
Russell
Yes, with one declaration, the compiler remember the type. :)

Win98 Athlon 1200 256DDR ATI RADEON 9000
Post Reply