Page 1 of 1

More On My Substack Problems

Posted: Fri Oct 08, 2010 12:32 am
by WaltBrown
I think I may be out of luck but I am hoping for a clue. Here is the Summary of the "Find" command: "Searches the fields of the current stack", the operative word being "current".

Here is the single line (in many forms) I cannot get to work in a function call in one stack, when the function is called from a button in another application stack:

Code: Select all

find pBackName in fld "fWords"
find pBackName in fld "fWords" of the name of me
find pBackName in fld "fWords" of me
find pBackName in fld "fWords" of stack "sNames"
find pBackName in fld "fWords" of stack the short name of me
find pBackName in fld "fWords" of this stack

put "fWords of this stack" into tFieldName
find pBackName in fld tFieldName

put "field" && quote & "fWords" & quote && "of me" into tFieldName
find pBackName in tFieldName
It always executes "find" in the application stack, not the library stack (sNames), even when I try to tell it which stack to use. If I add a field "fWords" to the application stack, it always works (all of the above lines act identically), but of course that is not where I want it to search. I cannot seem to be able to make "find" execute in the library stack, it insists on running in the defaultStack. Basically what I am finding is that "find" just ignores the "of" clause in every case, and without error. Unfortunately none of the other search functions will search through a named field in every card in a stack.

I am really trying to avoid having to do this on every function call, because it turned out to be inconsistent since some of my function calls call others, many of the functions have multiple exit points. and it adds a tremendous amount of code. It looks simple here, but in a complex function set it is unusable:

Code: Select all

local tDefaultStackName
put the defaultStack into tDefaultStackName
set the defaultStack to "sNames"
find pBackName in fld "fWords"
if (someTestCondition) then 
    set the defaultStack to tDefaultStackName
    return "Exited because of XXX"
end if
--call some other functions which also need to set defaultStack and also have multiple exit points
set the defaultStack to tDefaultStackName
return "Exited because of YYY"
...
FYI, I am making sub stacks as pseudo-SQL tables during development and testing, that's why the data resides in the sub stacks. Only those that get to a certain size will transition to SQL, but they all have the same basic set of function calls.

I want to avoid the defaultStack complexities. My only other thought is going async (wait on a return event from the library stack) or brute force (repeat for each card, etc), but that's an entire new set of compexities.

Thoughts? Or are we all stuck with this? Thanks, Walt

Re: More On My Substack Problems

Posted: Fri Oct 08, 2010 1:22 am
by WaltBrown
Here's the workaround I made, a basic LIFO:

Code: Select all

global gStack

on wPush pNewStack
   put the defaultStack & return before gStack
   set the defaultStack to pNewStack
end wPush

on wPop
    set the defaultStack to line 1 of gStack
    delete line 1 of gStack
end wPop
I surround every operation which makes assumptions about defaultStack with:

Code: Select all

local tResult

wPush me
find tSomething
-- Deal locally with the result and the found stuff
find empty
wPop
It still adds a bit of code, and I need to have extra vars for the "found" info, etc.

Walt

Re: More On My Substack Problems

Posted: Fri Oct 08, 2010 6:34 pm
by Regulae
Hi Walt,

I’m afraid I don’t have any useful advice on this problem at present. In fact, I have yet to have the specific search requirement you describe- but the day is sure to come. When it does, I will enjoy a considerable advantage because you posted such a clear statement of the problem, the various approaches you tried, and the eventual solution you arrived at, which is indeed elegant. I just thought I’d thank you in advance.

Regards,
Michael

Re: More On My Substack Problems

Posted: Sat Oct 09, 2010 12:28 pm
by WaltBrown
Thanks Michael, that was very generous. I'll have to get a new hat.
Walt