Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 record syntax.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Justin_




PostPosted: Wed Jan 18, 2006 6:43 pm   Post subject: record syntax.

Hi, is there anything wrong with this code:

code:

type webData :
        record     %struct equivelant
            list_urls   : flexible array 1 .. 2 of string
            searchTerm  : string
            url_count   : int    %To determine how many links there are.
            lines       : string
            url         : string
            file_stream : flexible array 1 .. 2 of int
        end record


it says syntax error at "flexible"
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Wed Jan 18, 2006 6:54 pm   Post subject: (No subject)

Sadly, Turing can't handle flexible arrays within records. It's one of Turing's biggest problems, in my opinion.

The best you can do is declare a big hoinking static array ( Wink ) and use an index variable to keep track of the "upper" of it.
Justin_




PostPosted: Wed Jan 18, 2006 8:31 pm   Post subject: (No subject)

how unfortunate Crying or Very sad yeah the static array will have to do.
Tony




PostPosted: Thu Jan 19, 2006 12:01 pm   Post subject: (No subject)

Cervantes wrote:
Sadly, Turing can't handle flexible arrays within records. It's one of Turing's biggest problems, in my opinion.

How would you go about implementing it? Suddenly you'll have a record type of arbitrary length. There will be a whole bunch of problems with reserving a correct amount of space and then adjusting it on per-record basis.

If you are dealing with a lot of data and do want to have it stored in a flexible array, you could declear it outside of the record definition, and point to it from within the record.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
MysticVegeta




PostPosted: Thu Jan 19, 2006 12:41 pm   Post subject: (No subject)

Well what you could have is a record inside a record.
codemage




PostPosted: Thu Jan 19, 2006 1:41 pm   Post subject: (No subject)

Why jump through so many hoops to use a special Turing shortcut?

Flexible arrays are just a Turing-specific training-wheels-enabled version of dynamic lists.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: