Re: returning result from a function when the number of items in the result varies

2008-09-22 Thread Trevor DeVore
On Sep 22, 2008, at 12:26 AM, Ken Ray wrote: Has an element in an array been defined yet? put key is among the lines of (the keys of arrayVariable) - true if it has been defined, false if it has not been defined One additional

Re: returning result from a function when the number of items in the result varies

2008-09-22 Thread william humphrey
Thanks again. I'm going to fool with. Does an element in an array have a value? -- put arrayVariable[key] is not empty - true if it has a value, false if it does not So far the array is doing exactly what I wanted it to. And it is also

Re: returning result from a function when the number of items in the result varies

2008-09-21 Thread Jim Ault
If there is no real reason to use an array in the function, then I would avoid it since your function may generate two 'hits' that happen to have the same key. In that case, only one answer will be returned since keys have to be unique. If you are transferring simple data, why not use the

Re: returning result from a function when the number of items in the result varies

2008-09-21 Thread william humphrey
Thanks again. I'm still curious about the array. When I use the number of lines in myArray I get the correct answer 1 before I send it out of the function as myArray but when I do the same number of lines in myArray after it is called then the answer is 0. If I ask for one key in the array (as

Re: returning result from a function when the number of items in the result varies

2008-09-21 Thread william humphrey
My mistake. Please ignore last post. Brain works better in morning. The array is returning correctly. I was just testing the results wrong. It looks like this is going to work and I think that it is much better to use the array as the key is generated by the data identifier and will thus be

Re: returning result from a function when the number of items in the result varies

2008-09-21 Thread Stephen Barncard
It's not a list! It's an array. It's not THE NUMBER OF LINES in myArray. it's the number of lines in the KEYS of myArray. Big difference. I'll build a silly array here: set the itemdelimiter to comma put Jefferson,Washington,Lincoln,Bush,Elvis into historyList repeat with n = 1 to number of

Re: returning result from a function when the number of items in the result varies

2008-09-21 Thread Stephen Barncard
The results in examples 1 and 2 were incorrect. put myArray [1] return into toadMeatList put myArray [2] return after toadMeatList put myArray [5] after toadMeatList RESULTS-- Jefferson Washington Elvis or in a regular loop put 1,2,5 into orderList repeat with n = 1 to numLines put

Re: returning result from a function when the number of items in the result varies

2008-09-21 Thread william humphrey
Thanks again. I've got it now. I've noticed that the put number of lines in the keys of myarray -- returns a number that is the same whether or not an element in the array contains data. So the number of lines in the KEYS of myArray is not a good test to see if an array has data or even how many

Re: returning result from a function when the number of items in the result varies

2008-09-21 Thread Ken Ray
So the number of lines in the KEYS of myArray is not a good test to see if an array has data or even how many lines of data are in the array. True. Here's some basic tests (- means returns): Is a Variable an Array? -- Rev 2.x: the keys of variable -- If

Re: returning result from a function when the number of items in the result varies

2008-09-20 Thread Joe Lewis Wilkins
William, When I needed to do something like this in HC, I'd build a string consisting of several comma delimited words/values and return that string. Then I'd evaluate the string for what I needed. That should work in Rev as well. It's kind of like using an array, I suppose. (smile) HTH

Re: returning result from a function when the number of items in the result varies

2008-09-20 Thread Mark Smith
William, you've got the idea. Arrays are really useful in these circumstances, and are really worth becoming familiar with. Best, Mark On 21 Sep 2008, at 01:13, william humphrey wrote: I'm having trouble sorting this out. I have a function that searches through lines of tab delimited

Re: returning result from a function when the number of items in the result varies

2008-09-20 Thread Stephen Barncard
You've practically designed it! Arrays are your friend. { below not tested} function yourFunction arrayVar put Timestamp tab FDSFSDF into myArray[garbage] put toad into myArray[green] return myArray end yourFunction put yourFunction() into Array combine array with return and tab put

Re: returning result from a function when the number of items in the result varies

2008-09-20 Thread william humphrey
Thanks for not only answering but giving me the example. The repeat for each line in the array will work perfectly. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your

Re: returning result from a function when the number of items in the result varies

2008-09-20 Thread william humphrey
for some reason in my function if I say return myArray then I get an array with zero lines even when that is not true. If I say return myArray[1] (where 1 is one of the keys which has data in the array) then it does return that correctly but just with that one line of course. This is why I

Re: returning result from a function when the number of items in the result varies

2008-09-20 Thread Stephen Barncard
HEY! that's not fair to the arrays. :) They REALLY are useful and amazing. Honestly, once you have you're aha moment you'll understand it. Your code is working as expected. For now, Just imagine the array to be a package of little ordinary variables that can be easily manipulated. put

Re: returning result from a function when the number of items in the result varies

2008-09-20 Thread Richard Gaskin
william humphrey wrote: for some reason in my function if I say return myArray then I get an array with zero lines even when that is not true. If I say return myArray[1] (where 1 is one of the keys which has data in the array) then it does return that correctly but just with that one line of