Making the move...

Jim Ault JimAultWins at yahoo.com
Fri Mar 24 13:19:14 EST 2006


On 3/21/06 4:55 PM, "Sarah Reichelt" <sarah.reichelt at gmail.com> wrote:
> The alternatives that I see are to use script local variables or to
> pass an empty parameter by reference and have the function fill it.
> Does anyone have any other ideas or recommendations?

Here is another way that you could take advantage of 'for each' and use one
function, scanning the database one time, returning multiple results in one
variable, without using an array.

on scan
--define var dbTable
  put dbScanner(dbTable) into dbEssence
  set the itemdel to "^"
  put item 1 of dbEssence into summer
  put item 2 of dbEssence  into lister
  put item 3 of dbEssence  into chimps
  
end scan

function dbScanner @dbTable
set the itemDel to tab  --if this is correct
  repeat for each line LNN in dbTable
    put "," & item 6 of LNN after itemsToSum
    put item 4 of LNN & cr after listofItem4
    if LNN contains "circus monkey" then
      put LNN & cr after monkeyLines
    end if
  end repeat
  get sum(itemsToSum)
  filter listofItem4 without empty
  filter monkeyLines without empty
  return it & "^" & \
      listofItem4 & "^" & \
      monkeyLines
  
end dbScanner

Jim Ault
Las Vegas

On 3/21/06 4:55 PM, "Sarah Reichelt" <sarah.reichelt at gmail.com> wrote:

> On 3/21/06, Geoff Canyon <gcanyon at inspiredlogic.com> wrote:
>> Do you have an example? I agree that if you end up passing in a
>> handful of arguments by reference, you haven't accomplished much by
>> breaking out the routine. The question is if there isn't a better way
>> to slice the routine, where that wouldn't be necessary.
>> 
> 
> OK, I have a better example. Say I have a data set and I need to loop
> through it and extract three different pieces of information e.g. a
> list of the 4th column in each line, a list of lines that match a
> certain set of criteria, and a cumulative total obtained by adding a
> certain column in each line.
> 
> Each of these could be done in a separate function, but that would
> mean looping through the data set three times. With a large data set,
> it is significantly faster to loop once, filling all three new
> variables in the single loop. If I separate this off into a separate
> function, then I need a way of passing multiple results back.
> 
> The alternatives that I see are to use script local variables or to
> pass an empty parameter by reference and have the function fill it.
> Does anyone have any other ideas or recommendations?
> 
> Sarah
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the Use-livecode mailing list