Function blocks explained
Chuck
15 Sept 2003, 21:42Can someone explain the uses of a function block? The manual is very sketchy on this, using the example,
$myfunction (3,potoato;sausage)$
without any explanation. Could someone enlighten me as to what could be going on in this example?
I read that a function returns a value. I understand that. If you want to insert an object's article into a message (HER apple), you have to use a function:
".....$objectproperty(mother; article)$ apple...."
What is a function block? More importantly, can someone give story examples (not the code, just an explanation) of why a function block is useful?
Thanks.
Chuck
$myfunction (3,potoato;sausage)$
without any explanation. Could someone enlighten me as to what could be going on in this example?
I read that a function returns a value. I understand that. If you want to insert an object's article into a message (HER apple), you have to use a function:
".....$objectproperty(mother; article)$ apple...."
What is a function block? More importantly, can someone give story examples (not the code, just an explanation) of why a function block is useful?
Thanks.
Chuck
paul_one
15 Sept 2003, 22:23A function is a procedure you write yourself which does whatever you want when you pass it values...
Although why these values can't be variables I don't know (maybe an error - I can't pass variables, just variable names are passed... Not values.).
Say you wanted something printed out a number of times - if you use this in many places then you write a function using parameters. Then when you call the function you pass it the parameters and have it print out whatever you want however many times you want.
_________________
Computer Whizz
==Insert Sig Here!==
Currently Listening To :
Barenaked Ladies - Pinch Me
Using Winamp.
Although why these values can't be variables I don't know (maybe an error - I can't pass variables, just variable names are passed... Not values.).
Say you wanted something printed out a number of times - if you use this in many places then you write a function using parameters. Then when you call the function you pass it the parameters and have it print out whatever you want however many times you want.
_________________
Computer Whizz
==Insert Sig Here!==
Currently Listening To :
Barenaked Ladies - Pinch Me
Using Winamp.
Alex
16 Sept 2003, 06:43
Although why these values can't be variables I don't know (maybe an error - I can't pass variables, just variable names are passed... Not values.).
What version are you using? Can you send me an ASL file please?
paul_one
16 Sept 2003, 13:20Oops
!
I was passing variables to procedures - not functions...
Still, should passing a value to a procedure be any different than to a function?
_________________
Computer Whizz
==Insert Sig Here!==
Currently Listening To :
NO SONG
Using Winamp.
I was passing variables to procedures - not functions...
Still, should passing a value to a procedure be any different than to a function?
_________________
Computer Whizz
==Insert Sig Here!==
Currently Listening To :
NO SONG
Using Winamp.
Alex
16 Sept 2003, 14:24Passing a variable to a procedure ought to work as well, as far as I know, though I can't recall explicitly testing it. I'll take a look into it.
kewldude606
16 Sept 2003, 22:06Functions are made for things you do a lot. If you had a procedure, it would take up more code...In some cases.
I personally think that they are more useful than procedures in cases where you need to have something return, obviously. Functions also make your code more reasonable. Look below...
or
Less typing for funtions
I personally think that they are more useful than procedures in cases where you need to have something return, obviously. Functions also make your code more reasonable. Look below...
...
msg <#ReplyForGirlWhenTalkingToFrog#>
...
or
...
msg <$Talk(Girl,Frog)$>
Less typing for funtions
Chuck
17 Sept 2003, 00:34Kewl, I just read your post. Sorry, but neither of your examples do anything to help me understand. Pretend you are talking to a very slow sixth grader (which is what I feel like on this issue).
How in heaven's name would you use a function
in a story? What does this function allow you to do in plain English? And why not use the term
as the text variable in your first example? Just adding a bunch of letters in the first example doesn't clarify why the second function is better.
I appreciate your response, but your code examples are confusing to me. Sorry.
Chuck
How in heaven's name would you use a function
msg <$Talk(Girl,Frog)$>in a story? What does this function allow you to do in plain English? And why not use the term
msg <#ReplyToFrog#>as the text variable in your first example? Just adding a bunch of letters in the first example doesn't clarify why the second function is better.
I appreciate your response, but your code examples are confusing to me. Sorry.
Chuck
GameBoy
17 Sept 2003, 14:33i would also like to know what the difference is between procedures and functions, i never used functions, they look, and act like procedures so i never bothered with them lol
paul_one
17 Sept 2003, 16:57Functions return a value - they're *usually* better for maths (passing it some values and returning a result from them) but are also good for returning letters, words or sentances.
Say you wanted to know the complex complication of:
(((X/3)^4)*Y)-7Z
And perhaps you use it all over the place in your program. You would write a FUNCTION and pass it X, Y & Z. It would then return the answer.
Maybe you had a "talk" function that looked at who you were talking to and decided an appropriate answer depending on the amount of times you have talked to that person. You can pass the object you're talking to, on to a function and have it add one to a certain variable and decide on the response.
Personally functions are of no use to me! I would use them in VB since variables can be restricted to certain parts of the code - but Quest has global variables, so there's no real point!
_________________
Computer Whizz
==Insert Sig Here!==
Currently Listening To :
NO SONG
Using Winamp.
Say you wanted to know the complex complication of:
(((X/3)^4)*Y)-7Z
And perhaps you use it all over the place in your program. You would write a FUNCTION and pass it X, Y & Z. It would then return the answer.
Maybe you had a "talk" function that looked at who you were talking to and decided an appropriate answer depending on the amount of times you have talked to that person. You can pass the object you're talking to, on to a function and have it add one to a certain variable and decide on the response.
Personally functions are of no use to me! I would use them in VB since variables can be restricted to certain parts of the code - but Quest has global variables, so there's no real point!
_________________
Computer Whizz
==Insert Sig Here!==
Currently Listening To :
NO SONG
Using Winamp.
Chuck
17 Sept 2003, 17:14Thanks a lot CW. You comments helped clear away a good portion of the fog. Your comment:
was especially helpful. Is there anything a function can do that you can't do in a global variable?
Chuck
Say you wanted to know the complex complication of:
(((X/3)^4)*Y)-7Z
And perhaps you use it all over the place in your program. You would write a FUNCTION and pass it X, Y & Z. It would then return the answer. was especially helpful. Is there anything a function can do that you can't do in a global variable?
Chuck