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

Username:   Password: 
 RegisterRegister   
 Functions inside records
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Danjen




PostPosted: Mon Mar 12, 2007 12:03 am   Post subject: Functions inside records

Here's what I have so far:
code:

var Skill :
    record
        Firebolt : fcn
            Firebolt (sLv, intH : int) : real
    end record

put Skill.Firebolt(5,10)

It displays a variable has no value error ... where and how would I correct this?
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Mon Mar 12, 2007 6:50 am   Post subject: Re: Functions inside records

that's because you have not given Firebolt any value. All it knows is that Firebolt should hold a function with two integer parameters. You have to create the function outside of the record, and assign that function to Firebolt like so:

Turing:

fcn firebolt (sLvl, intH : int) : real
    result 5 %just randomly
end firebolt

var skill :
     record
         spell : fcn foo (sLvl, intH : int) : real
     end record

skill.spell := firebolt

put skill.firebolt (10, 22)


Wink
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  [ 2 Posts ]
Jump to:   


Style:  
Search: