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

Username:   Password: 
 RegisterRegister   
 Compile Time Expression Expected Error with records
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HairyDonut




PostPosted: Wed Dec 07, 2011 10:18 am   Post subject: Compile Time Expression Expected Error with records

What is it you are trying to achieve?
I am trying to make a record variable to store information about students in a database of student applications. I am using a record because our teacher insists we include all elements we "learned" this semester.


What is the problem you are having?
When I try to define a variable, StudentActive, as the record type turing just gives me a compile time expression error, and tells me that where I defined my next variable there was an expected "..".

Describe what you have tried to solve this problem
Asked my teacher and classmates for help, Searched turings documentation on records, and search compile text expression errors discussions on this forum. All I've learned is that compile time expression errors are errors of the program trying to define a variable before the space for it exist, correct me if I'm wrong.


Post any relevant code


Turing:


var StudRecord :
    record
        Name : string
        StudID : string
        GradeLevel : string
        GradeAverage : string
        Recommender : string
    end record
var StudentActive : StudRecord
var Calibri : int := Font.New ("Calibri:11") % Included this line so you could see the ".." error.



Please specify what version of Turing you are using
either 4.1.1 or 4.1, not certain as it is the school standard, but it should be 4.1
Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Wed Dec 07, 2011 11:02 am   Post subject: Re: Compile Time Expression Expected Error with records

When you define a variable, you must also assign it a type. Here you are giving it a variable as a type instead of a type. The compiler error is because a variable can change value while your program is running, so its value cannot be determined at compile time.

What you want is to define a type, like this:

Turing:
type myRecord:
  record
    myInt : int
    myString : string
    % etc.
  end record

var myVar : myRecord
HairyDonut




PostPosted: Thu Dec 08, 2011 9:40 am   Post subject: RE:Compile Time Expression Expected Error with records

Ohhhh I get it thanks. That was part of the lesson, I just didn't notice the type instead of var.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: