Page 1 of 1

handler objects on other cards

Posted: Thu Oct 18, 2007 12:49 am
by churchken
Hi,

Is it possible to force a card script handler running on card"A" to limit its field object references to only that card, without adding ( of card"A" ) after every field reference in the entire handler?

This came up when I took a card with many fields and a script that calculates values for those fields, and "added" it to another stack. If I "go to " a different card in the stack while the first card handler is still working, errors pop up because the handler wants to put a value into a field that is not on the new card, but is on the original card.

Hope that makes sense, and thanks for any help.

Ken

Posted: Thu Oct 18, 2007 2:30 am
by Mark
Hi Ken,

I wonder why your script is still running while you go to a different card already. Figuring out why this happens and whether it is really necessary is probably an important part of the actual solution.

You could write a script that stores all values in variables until all repeat loops have finished and the values can be put into fields. Such a script might look like this.

Code: Select all

on longCalculation
  -- zillions of lines in myData
  repeat with x = 1 to (number of lines of myData)
    -- do something with line x of myData
    -- store values in an array if necessary
    put myResult1 into myValuesArray["put short name of field 1 here"]
    put myResult2 into myValuesArray["put short name of field 2 here"]
    -- and so on
    put myResultX into myValuesArray["put short name of field X here"]
  end repeat
  -- any more results to be stored?
  put myResultY into myValuesArray["put short name of field Y here"]
  put myResultZ into myValuesArray["put short name of field Z here"]
  -- go to card with the field without bothering user
  push cd
  lock screen
  go cd 1 -- card containing the fields that need to be filled out
  -- now we're finally done and can put values into fields
  repeat for each key myKey in myValuesArray
    put myValuesArray[myKey] into fld myKey
  end repeat
  pop cd
end longCalculation
Best,

Mark

different, on-going tasks

Posted: Thu Oct 18, 2007 1:30 pm
by churchken
Mark,

Thanks for your coding suggestion.

There is a "why" to go from one card to another while handlers are still working on each card. There is "new data" continuously being fed into each card via a socket connection to another program. Each card has its own "tasks", but I would like to be able to view the status of each card without halting the tasks being carried out on the other card.

Perhaps REV does not "like" this approach, and I need to separate the tasks into stand alone applications. This is not ideal for me, since the results of tasks on both cards are ultimately used in combination with each other in a third decision tree.

Thanks for any additional suggestions you might have.

Regards,
Ken

Posted: Thu Oct 18, 2007 1:37 pm
by Mark
Hi Ken,

One more question. Why is it inconvenient or problematic to add "of card xxxx" to your code?

Mark

Posted: Thu Oct 18, 2007 1:49 pm
by churchken
Mark,

If there is no simpler way, then adding "of card A" is probably what I will do.

It is a matter of convience not to do so, since future duplication of the handler script that is being used on card A (for use on cards "B" and "C", etc. ) is probable. Yes, :D , I do know how to use an editor.

Anyway, thanks for your assistance.

Regards,
Ken

Posted: Thu Oct 18, 2007 1:59 pm
by Mark
Hi Ken,

Why would you duplicate a handler? Why don't you raise the handler to the level of the stack script and adjust it to make it understand parameters that contain the id of the card?

Best,

Mark

Posted: Thu Oct 18, 2007 2:11 pm
by churchken
Mark,

That makes perfect sense, and in the long run is the best idea.

Thanks so much,
Ken