Arrays using longhand in other data types
BlitzMax Forums/BlitzMax Beginners Area/Arrays using longhand in other data types
| ||
Is there a way to make arrays in "longhand" using other types besides Int, Float, and String?global floatarray :float[] = [0.00,0.01,0.02] 'works global doublearray :double[] = [0.00,0.01,0.02] 'does not work global bytearray :byte[] = [1,2,3,4,5] 'does not work |
| ||
global bytearray :byte[] = [Byte(1),Byte(2),Byte(3),Byte(4),Byte(5)] 'does not work BlitzMax just does not know that "1,2,3,4,5" are also potential Bytes. Maybe it is to avoid "logic" in the compiler/parser/whatever as it then would have to check if "byte casted 5" is a valid byte or now somehow "null" (a real null, not a default "0" which is the case with ints in BlitzMax) bye Ron |
| ||
You should (can't check right now) be able to do this to force the type of a literal value:doublearray = [0.0:Double, 0.1:Double, 0.2:Double] bytearray = [1:Byte, 2:Byte, 3:Byte] You can also use the BASIC type sigils if you prefer them (#, !, % etc). |
| ||
I know the sigils can be used in variable names, and I tested them out with in-line expressions and they seem to work out just fine. This is probably what I'm looking for. What do each of the symbols mean when appending them to the end of literals? I know # is Float. I think % is Int and ! is Double? Where can I find a list of these? EDIT: Nevermind, I found it in "BASIC compatibility" in MaxIDE's reference. Looks like there's only four. $ String # Float ! Double % Int Would be nice to have other sigils for things like Short and Byte though. Perhaps: @ Short & Byte global shortarray:short = [1@,2@,3@,4@,5@] global bytearray:byte = [1&,2&,3&,4&,5&] |
| ||
http://blitzbasic.com/Community/post.php?topic=77677&post=869747 |