2 random questions

BlitzMax Forums/BlitzMax Beginners Area/2 random questions

djdee(Posted 2007) [#1]
*1 Is there an equivalent in bmax to enum in c++, where you can create custom values to be used in runtime?

*2 how exactly does the garbage collector work, and is there a need to use smart pointers with reference counting and stuff if you want to work with byte ptr ?

*3 when you use the incbin feature, is it possible to store textfiles and modify them during runtime and having them saved when you close the program. Basicly, to keep data files within the exe so you can have one standalone file, for small programs.


djdee(Posted 2007) [#2]
ops 3 random questions, whatever, hehe :)

oh, one more..

in these forums, how do you create code examples ? something like [code] or similar ??


H&K(Posted 2007) [#3]
[code][/cdoe]
(spelt wrong delibratly ;) Or the same with codebox

1) NO, well I say no, you could write them out one at a time. But really no
2 It just does. I dont think so, I just ignore the whole thing
3) Errr dont know.


JazzieB(Posted 2007) [#4]
1. I'm no C++ expert, but are enum's constants? If so, then yes, use Const. If not, then, err, probably not!

2. The GC just works, by killing any objects that are no longer pointed to by a pointer/reference. I don't think it works with Byte Ptr, but then, I haven't used pointers very much.

3. No. You can't save back to an incbin'd file.


H&K(Posted 2007) [#5]
@Jazzie,
Enums are constants, but you dont assign the values to them, you just give the first value. Thats why if you look at some c++ listings you often see a big list of just constat names. In Bmax you have to assign each value


The r0nin(Posted 2007) [#6]
Re#1: Unless something has changed, no BM doesn't have enums. For Jazzie, the key to an enum is that the compiler generates the values so that none are matching (if I set Red=1, Black=2, Green=4, etc. manually, I could accidentally make another constant = 2 later and end up with issues)

Re#3: Why not read in the data from the file you want, then make a file in the dir of your program and copy the data into it. You can have your program check for the file first in the home dir, and if it doesn't find it, follow the above process.


SculptureOfSoul(Posted 2007) [#7]
#2: If you want your byte pointers to be taken care of without manual intervention then yes, I'd make a smart pointer class and wrap that around the byte pointers.


ImaginaryHuman(Posted 2007) [#8]
#3 you probably can't, you can't modify the exe and save it while it is running, you won't be allowed access by the o/s (i think). That would be like self-modifying code. If you want a permanent change you need to load the file at runtime.


FlameDuck(Posted 2007) [#9]
Enums are constants, but you dont assign the values to them, you just give the first value.
Ofcourse real enums are typesafe, so they don't have any values assigned to them.


H&K(Posted 2007) [#10]
oh