It is currently Sun May 19, 2013 9:15 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: automatic data typing
PostPosted: Fri May 11, 2012 4:52 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 793
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:
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:
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.


Top
 Profile  
 
 Post subject: Re: automatic data typing
PostPosted: Fri May 11, 2012 5:09 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 711
Location: Germany, Glienicke
and what is
Code:
data 0


byte, acsii, word, unicode, long, quad, float, double ???

_________________
Image


Top
 Profile  
 
 Post subject: Re: automatic data typing
PostPosted: Fri May 11, 2012 5:19 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jun 26, 2009 3:51 pm
Posts: 194
Location: Westernmost tip of Norway
I'd prefer the data, read etc. keywords to support structures. Would be more PB-style.
Code:
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

_________________
You never learn anything by doing it right.


Top
 Profile  
 
 Post subject: Re: automatic data typing
PostPosted: Fri May 11, 2012 5:43 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 793
STARGÅTE wrote:
and what is
Code:
data 0


byte, acsii, word, unicode, long, quad, float, double ???

Whatever your Default type was. In my example, I used .i.


Top
 Profile  
 
 Post subject: Re: automatic data typing
PostPosted: Fri May 11, 2012 5:44 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 793
KJ67 wrote:
I'd prefer the data, read etc. keywords to support structures. Would be more PB-style.
Code:
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!


Top
 Profile  
 
 Post subject: Re: automatic data typing
PostPosted: Fri May 11, 2012 6:09 pm 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1561
Location: Germany
Tenaja wrote:
KJ67 wrote:
I'd prefer the data, read etc. keywords to support structures. Would be more PB-style.
Code:
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


Top
 Profile  
 
 Post subject: Re: automatic data typing
PostPosted: Fri May 11, 2012 7:50 pm 
Online
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 2393
Location: Utah, USA
KJ67 wrote:
I'd prefer the data, read etc. keywords to support structures. Would be more PB-style.
Code:
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: [url]http://www.purebasic.fr/english/viewtopic.php?f=3&t=40966[/url]

Oh, and I'm still +1 for this. :)

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: MuuSer and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye