Labels and functions

BlitzMax Forums/BlitzMax Beginners Area/Labels and functions

Sledge(Posted 2007) [#1]
Is it possible to pass a label to a function as an argument?


Beaker(Posted 2007) [#2]
No, but it's possible to send a function (pointer) to a function as an argument.


Sledge(Posted 2007) [#3]
Blast. Select...Case then.


Dreamora(Posted 2007) [#4]
You can not use labels anyway in strict / superstrict if you mean labels like goto labels.
Strict only allows labels for loop lableing (to continue / exit encapsulated loop construct which was one of the things goto was really needed for)

Depending on what you might try to achieve, there might be another more efficient way.

Mind to share your target use?


Sledge(Posted 2007) [#5]
It's for use with RestoreData (I always fly SuperStrict, man) -- I'm writing a very simple tile system to underpin a shooter whimsy and I'm using Max's OOP-style types to let me encapsulate the system within a namespace (ie there are no instances of the tile system, the type declaration *is* the instance and its global vars are the fields that its functions can share). So far so neat, and I wanted to retain the neatness by doing something like...

tileSys.mapData(BGIndex:int,dataLabel:???) [which is an instruction to map the data at the data label to the given background]

...then within tileSys.mapData() I would RestoreData dataLabel. Instead it looks like I'll either have to RestoreData in the main code before calling mapData() or pass an integer and hard-code a Select...Case restore based on which portion of data the integer represents (ie if it's 1 then RestoreData levelOneData etc)

No biggy as this kind of data tends to end up in files anyway, I just would've liked to have been able to play about with inline data the same way (would rather concentrate on the tile system now and the file system later but hey ho...)


Dreamora(Posted 2007) [#6]
Oh, right, forgot about data because I always put the data external.

problem is that the data label is replaced on compilation with the adress within the programm where you can find the data. that is why something like this won't work as functions only exist at runtime where the labels do not exist anymore.


Paposo(Posted 2007) [#7]
Hello.

mmm. I not use DATA and RESTORE. i prefer use a file.
Incbin is one solution if you need include info in the .EXE.

żIs right for you?

Bye,
Paposo