
-----------------------------------
Big_Tom
Mon Mar 22, 2004 11:12 am

Clac won't work
-----------------------------------
I've tried everything and i can't get this to work...please help.

-----------------------------------
Delos
Mon Mar 22, 2004 12:42 pm


-----------------------------------
1)
In your procs/fcns, since you want to alter your parameters, declare them as variable...

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...

proc a (var b : int := 3)
end a
% Will not word.


3)
All fuctions must return a value:

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...)


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



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
Mon Mar 22, 2004 3:52 pm


-----------------------------------

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 :?

isntead of "number:=fcn(number)" do it like this

put fcn(number)

where fcn is the name of your function

ex:


fcn num(a:int):int
result a
end num

var b:int
put "Enter a number: "..
get b
put num(b)


-----------------------------------
Delos
Mon Mar 22, 2004 7:52 pm


-----------------------------------
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.
