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

Username:   Password: 
 RegisterRegister   
 Clac won't work
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Big_Tom




PostPosted: Mon Mar 22, 2004 11:12 am   Post subject: Clac won't work

I've tried everything and i can't get this to work...please help.


Roman2.t
 Description:

Download
 Filename:  Roman2.t
 Filesize:  2.04 KB
 Downloaded:  230 Time(s)


calcmodule.t
 Description:

Download
 Filename:  calcmodule.t
 Filesize:  6.44 KB
 Downloaded:  248 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Mon Mar 22, 2004 12:42 pm   Post subject: (No subject)

1)
In your procs/fcns, since you want to alter your parameters, declare them as variable...
code:

proc a (var b : int)
b := 3
put b
end a


2)
You cannot initialize vars/parameters at their declaration within a proc. Only after...
code:

proc a (var b : int := 3)
end a
% Will not word.


3)
All fuctions must return a value:
code:

function add (var num1 : int, var num2 : int) : int
result num1 + num2
end add

If you don't know how that worked, press F10 for more syntaxial help.

4)
You cannot call a function, only umm...'reference' it (I'm not sure of the technical term here...)

code:

fcn h (var num : int) : int
result num + 1
end h

var ans : string
var number : int := 4
put "Yes or no?"
get ans
if ans = "y" then
h(number)
end if
% This will not work.
put number


code:

fcn h (var num : int) : int
result num + 1
end h

var ans : string
var number : int := 4
put "Yes or no?"
get ans
if ans = "y" then
number := h(number)
end if
% This however, will work.
put number



That's all I could find.
Update and repost, will check again.
Thuged_Out_G




PostPosted: Mon Mar 22, 2004 3:52 pm   Post subject: (No subject)

Delos wrote:

var ans : string
var number : int := 4
put "Yes or no?"
get ans
if ans = "y" then
% number := fcn(number) %
end if
% This however, will work.
put number


the section i commented out doesnt really work Confused

isntead of "number:=fcn(number)" do it like this

put fcn(number)

where fcn is the name of your function

ex:

code:

fcn num(a:int):int
result a
end num

var b:int
put "Enter a number: "..
get b
put num(b)
Delos




PostPosted: Mon Mar 22, 2004 7:52 pm   Post subject: (No subject)

Thanks! I was in a rush when I typed it so I put 'fcn' instead of 'h' for those 2 examples.

I editted the post, so it reads correctly now.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: