Re: Passing parameters by reference

2012-03-13 Thread Dar Scott
Hi, Bob! On Mar 13, 2012, at 9:37 AM, Bob Sneidar wrote: > That is what passing an element to an array amounts to was my point. I think > what you are calling a statement many will call an expression. This concern is understandable. However, I think we can distinguish between an expression t

Re: Passing parameters by reference

2012-03-13 Thread Bob Sneidar
That is what passing an element to an array amounts to was my point. Bob On Mar 12, 2012, at 5:39 PM, Pete wrote: > I'm not sure whose post you're responding to Bob. Where do you see > something that amounts to a statement being passed as a referenced > parameter? > Pete > > On Mon, Mar 12,

Re: Passing parameters by reference

2012-03-12 Thread Dar Scott
On Mar 12, 2012, at 11:18 PM, Mark Wieder wrote: > You'd have to somehow prevent the dereferencing of myArray[myKey] in > order to pass it by reference. Just as the dereferencing of x would have be be prevented to pass it as reference. Perhaps any mutable place is the same. Dar _

Re: Passing parameters by reference

2012-03-12 Thread Mark Wieder
Pete- Monday, March 12, 2012, 5:39:16 PM, you wrote: > I'm not sure whose post you're responding to Bob. Where do you see > something that amounts to a statement being passed as a referenced > parameter? Here's the problem: a parameter of the form array["key"] is not a pointer to the "key" elem

Re: Passing parameters by reference

2012-03-12 Thread Pete
I'm not sure whose post you're responding to Bob. Where do you see something that amounts to a statement being passed as a referenced parameter? Pete On Mon, Mar 12, 2012 at 3:04 PM, Bob Sneidar wrote: > Just weighing in here, that would be a bit confusing. Passing by reference > means that the

Re: Passing parameters by reference

2012-03-12 Thread Bob Sneidar
Just weighing in here, that would be a bit confusing. Passing by reference means that the command or function has access to the variable passed to it. By passing what amounts to a statement, there is nothing for LC to manipulate on the other end. Statements have to have some place to put the res

Re: Passing parameters by reference

2012-03-12 Thread Dick Kriesel
On Mar 12, 2012, at 11:41 AM, Pete wrote: > I guess you might say Dick is array of sunshine in this dark world of LC we > live in? Oh, for Pete's sake! ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsu

Re: Passing parameters by reference

2012-03-12 Thread Dick Kriesel
On Mar 12, 2012, at 11:12 AM, Mark Wieder wrote: > Dick is well known as the master of arrays. I've learned to just > accept his advice without questioning. I didn't know that! But, I make so many misteaks that I have to recomend that you resume questoining. -- Dick ___

Re: Passing parameters by reference

2012-03-12 Thread Dick Kriesel
On Mar 12, 2012, at 10:19 AM, Pete wrote: > I'm wondering how you found about about this key values array feature? I > can't find any mention of it in the dictionary or the reference manual and > it sure seems like something that should be known! I found it while looking through bug reports for

Re: Passing parameters by reference

2012-03-12 Thread Pete
I guess you might say Dick is array of sunshine in this dark world of LC we live in? Pete On Mon, Mar 12, 2012 at 11:12 AM, Mark Wieder wrote: > Pete- > > Monday, March 12, 2012, 10:19:14 AM, you wrote: > > > I'm wondering how you found about about this key values array feature? I > > can't find

Re: Passing parameters by reference

2012-03-12 Thread Mark Wieder
Pete- Monday, March 12, 2012, 10:19:14 AM, you wrote: > I'm wondering how you found about about this key values array feature? I > can't find any mention of it in the dictionary or the reference manual and > it sure seems like something that should be known! Dick is well known as the master of

Re: Passing parameters by reference

2012-03-12 Thread Pete
Hi Dick, Thanks again for this tip. I ended up using it to solve my problem by passing the whole array variable along with an optional second parameter which is a list of comma-separated key values. The function turns the key values list into an array then uses it to access the data array. If th

Re: Passing parameters by reference

2012-03-10 Thread Pete
That would work but the complication is that the function is already returning true or false to indicate whether it changed the input or not so I can do something like: if modified(tvar) then --do something else --do something else end if If I change it to return the result of it's operation

Re: Passing parameters by reference

2012-03-10 Thread Dar Scott
Thanks for the tip, Dick, on using the list of keys. One can think of arrays as nested or multidimensional. On Mar 10, 2012, at 1:06 AM, Dick Kriesel wrote: > I agree it'd be good if LC could accept any array reference for invoking a > handler that specifies pass-by-reference. Though is is pro

Re: Passing parameters by reference

2012-03-10 Thread Dar Scott
On Mar 10, 2012, at 11:21 AM, Pete wrote: > I may as well just change the function to return the > result of its code and pass the parameter by value instead of reference. Hmm. Like this? put modified(a[s]) into a[s] This might be the best for now. Dar --- Dar Scott

Re: Passing parameters by reference

2012-03-10 Thread Pete
Dick: Thanks for the script, another little nugget of knowledge added to my LC store! I have entered an enhancement request - it's # 10070 Dar: The function in question is a general purpose one that gets called from many places. Sometimes I need to pass an array element and other times just a

Re: Passing parameters by reference

2012-03-10 Thread Dick Kriesel
On Mar 9, 2012, at 5:05 PM, Dar Scott wrote: > Maybe the array could be global (or passed as a parameter) and the subscript > passed. ... There might be problems I don't see right off, such as access to > the same array at two different levels at the same time. Hi, Dar. LC has a way to get a

Re: Passing parameters by reference

2012-03-09 Thread Pete
I have an update on this. If the parameter passed is simply the name of the array with no key qualifications, all is fine. LC only kicks up a fuss when you pass a qualified array like myArray[myKey]. Weird. Pete On Fri, Mar 9, 2012 at 5:05 PM, Dar Scott wrote: > Oh, that would be cool! > > M

Re: Passing parameters by reference

2012-03-09 Thread Dar Scott
Oh, that would be cool! Maybe the array could be global (or passed as a parameter) and the subscript passed. This works: add 1 to a["x"] ... it seems like a reasonable thing to do. There might be problems I don't see right off, such as access to the same array at two different levels at t

Re: Passing parameters by reference

2012-03-09 Thread Bob Sneidar
Yup. You can do something like this: put theArray[1] into theTempArray xyz theTempArray put theTempArray into theArray[1] Bob On Mar 9, 2012, at 3:30 PM, Pete wrote: > I think I already know the answer to this so just confirming in case I'm > missing something > > Let's say I have a handler w

Passing parameters by reference

2012-03-09 Thread Pete
I think I already know the answer to this so just confirming in case I'm missing something Let's say I have a handler with a parameter that is passed by reference, eg "command xyz @parm1". If I try to pass an element of an array, eg "xyz theArray[2]", I get a runtime error. If, however, I pass t