Page 1 of 1
automatic data typing
Posted: Fri May 11, 2012 4:52 pm
by Tenaja
Sometimes you need to build a table with multiple data types that must align. (i.e. a string containing a color name, and an int with the color value.)
This gets messy:
Code: Select all
datasection
data.s "White" : data.i $ffffff
data.s "Black" : data.i 0
enddatasection
Permitting multiple data types, and automatic types with strings would simplify this common use. If we could have a default setting for numbers, strings are easy to differentiate.
Code: Select all
datasection.i
data $ffffff , "White"
data 0, "Black"
enddatasection
I think constant arrays with multiple lines would be far superior, but this seems like a great in-between.
Re: automatic data typing
Posted: Fri May 11, 2012 5:09 pm
by STARGÅTE
and what is
byte, acsii, word, unicode, long, quad, float, double ???
Re: automatic data typing
Posted: Fri May 11, 2012 5:19 pm
by KJ67
I'd prefer the data, read etc. keywords to support structures. Would be more PB-style.
Code: Select all
Structure foo
x.i
y.s
z.f
EndStructure
Restore test
Define t.foo
Read.foo t
test:
DataSection
Data.foo 1, "Hi", 3.1415
EndDataSection
Re: automatic data typing
Posted: Fri May 11, 2012 5:43 pm
by Tenaja
STARGÅTE wrote:and what is
byte, acsii, word, unicode, long, quad, float, double ???
Whatever your Default type was. In my example, I used .i.
Re: automatic data typing
Posted: Fri May 11, 2012 5:44 pm
by Tenaja
KJ67 wrote:I'd prefer the data, read etc. keywords to support structures. Would be more PB-style.
Code: Select all
Structure foo
x.i
y.s
z.f
EndStructure
Restore test
Define t.foo
Read.foo t
test:
DataSection
Data.foo 1, "Hi", 3.1415
EndDataSection
I'd be happy with that!
Re: automatic data typing
Posted: Fri May 11, 2012 6:09 pm
by c4s
Tenaja wrote:KJ67 wrote:I'd prefer the data, read etc. keywords to support structures. Would be more PB-style.
Code: Select all
Structure foo
x.i
y.s
z.f
EndStructure
Restore test
Define t.foo
Read.foo t
test:
DataSection
Data.foo 1, "Hi", 3.1415
EndDataSection
I'd be happy with that!
Me too!
+1
Re: automatic data typing
Posted: Fri May 11, 2012 7:50 pm
by Demivec
KJ67 wrote:I'd prefer the data, read etc. keywords to support structures. Would be more PB-style.
Code: Select all
Structure foo
x.i
y.s
z.f
EndStructure
Restore test
Define t.foo
Read.foo t
test:
DataSection
Data.foo 1, "Hi", 3.1415
EndDataSection
Previous thread covering the same/similar subject:
http://www.purebasic.fr/english/viewtopic.php?f=3&t=40966
Oh, and I'm still
+1 for this.
