Re: difference between function and command and sending parameters
I noticed that you can't return a mix of an array and a variable. This doesn't work (it only works if the params are both simple variables or if you only have one parm - the array) : *on* mouseUp *put* the first item of MyTest() into myArray *put* the keys of myArray *end* mouseUp *function* MyTest *put* app into pfirst[1] *put* win into pfirst[2] *put* lin into pfirst[3] *put* 2 into psecond *return* pfirst, psecond *end* MyTest I needed to do something like the above as the second parameter held a different data item so now I'm trying to figure out another way to do it. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
William, if your example is as simple as it seems, I'd probaly not bother with an array, and use chunks instead, However, for bigger data I'd do something like this, in Rev 3.0 on mouseUp put myTest() into tBigArray put tBigArray[1] into myArray put tBigArray[2] into mySimpleVariable put the keys of myArray end mouseUp function myTest put app into tArray[1][1] put win into tArray[1][2] pit lin into tArray[1][3] put 2 into tArray[2] return tArray end myTest If you're still pre-3.0 then something like on mouseUp put myTest() into tArray put tArray[othervalue] into mySimpleVariable delete variable tArray[othervalue] put the keys of tArray end mouseUp function myTest put app into tArray[1] put win into tArray[2] put lin into tArray[3] put 2 into tArray[othervalue] end myTest best, Mark On 1 Dec 2008, at 22:19, william humphrey wrote: I noticed that you can't return a mix of an array and a variable. This doesn't work (it only works if the params are both simple variables or if you only have one parm - the array) : *on* mouseUp *put* the first item of MyTest() into myArray *put* the keys of myArray *end* mouseUp *function* MyTest *put* app into pfirst[1] *put* win into pfirst[2] *put* lin into pfirst[3] *put* 2 into psecond *return* pfirst, psecond *end* MyTest I needed to do something like the above as the second parameter held a different data item so now I'm trying to figure out another way to do it. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Thanks. My arrays aren't that big but i like how I can call them in repeat loops (I'm generating XML) ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
difference between function and command and sending parameters
subject was question that comes from programming without knowlege I always thought that to pass a parameter with a command it had to be a function like. function myfunction param -- do stuff with the param end myfunction but I just realized (from use actually) that you can do: command mycommand param -- do stuff with the param end mycommand and it works just as well. Of course you can also say: on mycommand param end mycommand and I guess on is a synonym for command Now (if you're bored and read this far) you can send a command to a script in another card or stack but you can't send a function. send mycommand param to card scripshere of stack mystack works fine. But you can't send a do myfunction(param) to a card so any functions that you write have to be in the default stack's script if you want to use them all over the place. So my question is twofold. 1. How do you send a do to a function. and 2. why would anyone use the function thing when they can use a command with a parameter. What good is a function? I guess when you want multiple parameters? ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
On a side note. In the script window functions are labeled with an F -- for function although in my case it's probably for fail. But commands are labeled H. What does the H stand for? ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Hopeless? ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Le 17 oct. 08 à 17:13, william humphrey a écrit : On a side note. In the script window functions are labeled with an F -- for function although in my case it's probably for fail. But commands are labeled H. What does the H stand for? ___ handler, probably. Comes from Hypercard. Cheers, François ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Bonjour William, Le 17 oct. 08 à 17:08, william humphrey a écrit : 2. why would anyone use the function thing when they can use a command with a parameter. What good is a function? I guess when you want multiple parameters? Functions are useful and handy because their main purpose is to return a value: set the enabled of group Commands to ThereIsAPilot() -- function ThereIsAPilot return William is among the lines of CurrentUsers() -- -- returned value will be a Boolean (TrueOrFalse) end ThereIsAPilot function CurrentUsers return fld Users of card Reference -- returned value will be a list of lines end CurrentUsers Etc. Consider this just to understand how it works. Actually commands can return a value also (using the result... that is actually a function :-) but it's less handy. More generally, think about commands (on, command) when this will lead to a result visible by the user in your GUI. And think about functions to get values you need to achieve a process. There would be hundred of pages to write about commands versus functions: see the user guide p. 121 and after. About F and H used in Rev 3.x script editor in lists, I assume that H means 'handler' and could be considered as incorrect since a function is a handler as commands are :-) And, after having verified, Rev docs name commands handlers... Best regards from Paris, Eric Chatonet. Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/ Email: [EMAIL PROTECTED]/ ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Thanks Eric. It sure helps to get a simple explanation like that in addition to the docs. It seems like I can never understand any simple program concept and use it properly without lots of examples and simple explanations. But what if the function CurrentUsers is in a card in some other stack that you are using? then how do you say: quote return William is among the lines of CurrentUsers() of card othercard in stack mystack end quote? ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Quick answers: In Rev you can choose which you want since function calls {can change the UI or data storage, etc}{return a string value} command handlers {can change the UI or data storage, etc}{return a string value} Most all programming languages have both types of 'handlers' by different names Commands or procedures Functions or methods --F put formatToDollars(32.45) into amtToDisplay --H formatAsDollars 32.45, european commas put the result into amtToDisplay --H send ( formatAsDollars 32.45, quoteeuropeanquote) to this card put the result into amtToDisplay --F put formatToDollars(32.45) into fcnToExecute do ( put fcnToExecute into amtToDisplay) answer amtToDisplay --H put quote into q put (formatAsDollars 32.45, qeuropean commasq) into cmdToExecute do ( cmdToExecute ) put the result into amtToDisplay answer amtToDisplay the above routines call these handlers --F function formatToDollars amt return $ amt end formatToDollars --H on formatAsDollars pAmt, pStylle if pStylle is european commas then replace . with comma in pAmt return commas pAmt else return periods pAmt end if end formatAsDollars There are other ways of sending and dealing with params that get to be rather complicated, but enjoyably so :-) Hope this helps. Jim Ault Las Vegas On 10/17/08 8:08 AM, william humphrey [EMAIL PROTECTED] wrote: subject was question that comes from programming without knowlege I always thought that to pass a parameter with a command it had to be a function like. function myfunction param -- do stuff with the param end myfunction but I just realized (from use actually) that you can do: command mycommand param -- do stuff with the param end mycommand and it works just as well. Of course you can also say: on mycommand param end mycommand and I guess on is a synonym for command Now (if you're bored and read this far) you can send a command to a script in another card or stack but you can't send a function. send mycommand param to card scripshere of stack mystack works fine. But you can't send a do myfunction(param) to a card so any functions that you write have to be in the default stack's script if you want to use them all over the place. So my question is twofold. 1. How do you send a do to a function. and 2. why would anyone use the function thing when they can use a command with a parameter. What good is a function? I guess when you want multiple parameters? ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Bonsoir William, Le 17 oct. 08 à 18:00, william humphrey a écrit : Thanks Eric. It sure helps to get a simple explanation like that in addition to the docs. It seems like I can never understand any simple program concept and use it properly without lots of examples and simple explanations. But what if the function CurrentUsers is in a card in some other stack that you are using? then how do you say: quote return William is among the lines of CurrentUsers() of card othercard in stack mystack end quote? No you can't write this :-( If you may send or call commands placed anywhere, you must have a function somewhere in the current message path. It's the reason why libraries (put in use) are mostly collections of functions. Actually, when you'll master these basics, you'll deduce the right architecture :-) Have fun ;-) Best regards from Paris, Eric Chatonet. Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/ Email: [EMAIL PROTECTED]/ ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Recently, william humphrey wrote: what if the function CurrentUsers is in a card in some other stack that you are using? then how do you say: quote return William is among the lines of CurrentUsers() of card othercard in stack mystack end quote? return William is among the lines of \ value(currentUsers(),card othercard of stack mystack) Regards, Scott Rossi Creative Director Tactile Media, Multimedia Design ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Thanks Jim. I will have to digest this and refer to it again. I am taking to putting nearly everything in the bg script of the default stack though as it is also easier to find later. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
william humphrey wrote: So my question is twofold. 1. How do you send a do to a function. You don't have to. Use this: get value(myfuction(),this card) The second part (this card) should be the script that holds the function; it may be the stack, a button, whatever. Put the correct script location in the second parameter. and 2. why would anyone use the function thing when they can use a command with a parameter. What good is a function? I guess when you want multiple parameters? Command handlers can take multiple parameters too. The two are basically the same, with the exception that functions more easily return values. You can return a value with a command handler as well, but then you need to check the result in the calling script to see what came back. This may be helpful: http://www.hyperactivesw.com/functions.html -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
Caution: There is no 'background script' in Rev, as there was in Hypercard. The 'stack script' exists in both Rev and Hypercard. Group scripts are used in Rev, and can behave as background groups, but put the script of group grUserControls into message box put the script of this stack into message box -- does not work put the background script of this stack into message box Jim Ault Las Vegas On 10/17/08 9:18 AM, william humphrey [EMAIL PROTECTED] wrote: Thanks Jim. I will have to digest this and refer to it again. I am taking to putting nearly everything in the bg script of the default stack though as it is also easier to find later. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
I meant by bg script the script of the default stack which is the one you can call functions and commands from without trouble (maybe there should be a short cut name for it). I thought of another more complex way, go around setting the default stack but I remember trying it and getting in-consistent results. Thanks for helping with the description of get value -- you don't see it used very often in example scripts. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: difference between function and command and sending parameters
look up start using in the docs. After this is done the stack is available to the current stack and all others running at the time. Comments: The start using command places a stack's script into the message path after the current stack and before any objects in the backScripts. When you start using a stack, the libraryStack message is sent to the stack. When a standalone application is running, it can insert up to fifty stacks into the stacksInUse. This limit is set by line 3 of the scriptLimits function. When using the development environment, you can insert any number of stacks into the message path. I meant by bg script the script of the default stack which is the one you can call functions and commands from without trouble (maybe there should be a short cut name for it). I thought of another more complex way, go around setting the default stack but I remember trying it and getting in-consistent results. Thanks for helping with the description of get value -- you don't see it used very often in example scripts. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution -- stephen barncard s a n f r a n c i s c o - - - - - - - - - - - - ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution