Posted: 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
Posted: 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
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
Posted: 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.