Page 1 of 1

SubStack messes up put statement

Posted: Thu Apr 09, 2020 11:11 am
by mrcoollion
Good afternoon LC friends,

I have the following issue and it probably has to do with message paths but I cannot see a solution.

I have a substack with a spinner on it that I want to open from a card (in 'On openCard') and show on top before I start a command and close after the command is finished. The command resides in the main stack and has a put command that puts information into a field on the Card I called the command from. I do not have to add the card name to the put command because the message path recognizes that the command has been called from the card on which the field resides. This works fine until I open the substack before I call the command and then the command cannot find the field anymore to put the data in.

Is there any solution for this?

Regards,

Paul

Re: SubStack messes up put statement

Posted: Thu Apr 09, 2020 11:14 am
by Klaus
Dag Paul,

what did you script so far?


Best

Klaus

Re: SubStack messes up put statement

Posted: Thu Apr 09, 2020 12:22 pm
by mrcoollion
Hoi Klaus,

This is the structure of the code I use for starting and stopping the widget spinner which is on a substack called "WaitSpinner".
So in a card "JustACardName" with a field named "FieldnameOnCard" I use the code

Code: Select all

StartSpinner
DoWhatINeedToDo
StopSpinner
The StartSpinner, StopSpinner and DoWhatINeedToDo commands ared in the main stack.

Code: Select all

command StartSpinner
   ## Use SCREEN coordinates directly!
   put globalloc(the topLeft of stack "TradeBot_Tests") into tsavedTopLeft
   ## Add H and V offset
   add 180 to item 1 of tsavedTopLeft
   add 100 to item 2 of tsavedTopLeft
   open stack  "WaitSpinner"
   set the topLeft of stack "WaitSpinner" to tsavedTopLeft
end StartSpinner

command StopSpinner
   close stack "WaitSpinner"
end StopSpinner

command DoWhatINeedToDo 
put "This text I need to show" into fld "FieldnameOnCard"
end DoWhatINeedToDo 
That basically it.
Of course the actual code is not this but this is the structure (working on an AI trading Bot so I need to show the spinner while the bot is retrieving data from the internet or when a lot of calculations need to be made that take a little while).

Re: SubStack messes up put statement

Posted: Thu Apr 09, 2020 12:51 pm
by Klaus
Hi Paul,

hm, maybe one of these will help:

Code: Select all

command DoWhatINeedToDo 
   put "This text I need to show" into fld "FieldnameOnCard" OF CD X OF stack "the one with the field you want to put something in"
end DoWhatINeedToDo
Or:

Code: Select all

command DoWhatINeedToDo 
    set the defaultstack to "the one with the field you want to put something in"
    put "This text I need to show" into fld "FieldnameOnCard"
end DoWhatINeedToDo
Will also work if the substack is not open. :-)

Hint:
You can set the loc, rect etc. of a stack BEFORE you open it, so any flickering will be avoided.

Code: Select all

command StartSpinner
    ...
    ## First set properties:
   set the topLeft of stack "WaitSpinner" to tsavedTopLeft

   ## Then go to stack without flicker:
   open stack  "WaitSpinner"
end StartSpinner
Hope that help!


Best

Klaus

Re: SubStack messes up put statement

Posted: Thu Apr 09, 2020 3:50 pm
by mrcoollion
Bedankt Klaus,

I have placed the 'set the defaultstack to' line as the last line in the 'StartSpinner' command as well as the last line in the 'StopSpinner' command (to be sure) and I now have no problems anymore.

Thanks for your valuable help ( ... again ...) :D

PS.. Do you know a trick that removes the borderline of the substack or makes it only showing the spinner?

Re: SubStack messes up put statement

Posted: Thu Apr 09, 2020 3:56 pm
by Klaus
Graag gedaan! :-)
PS.: Do you know a trick that removes the borderline of the substack or makes it only showing the spinner?
You could use a WINDOWSHAPE and even animate it, but therefore you will need some PNGs images and "fake" the SPINNER
with these images while setting the windowshape.

Re: SubStack messes up put statement

Posted: Thu Apr 09, 2020 4:17 pm
by mrcoollion
Placed the following in the preOpenStack part of the WaitSpinner stack and I got what I was looking for.

Code: Select all

on preopenstack
   set the windowShape of this stack to the id of widget "Spinner" 
   set the style of this stack to palette
   set the blendLevel of this stack to  40
end preopenstack

Re: SubStack messes up put statement

Posted: Thu Apr 09, 2020 4:34 pm
by Klaus
REALLY? :shock:
I just tested this here and did not get what I exspected!

As far as I know WINDOWSHAPE only works with images!?

Re: SubStack messes up put statement

Posted: Thu Apr 09, 2020 5:03 pm
by jacque
Why not just show the spinner on the card in the mainstack?

You don't say whether this will be for desktop or mobile, but be aware you can't have two stacks open simultaneously on mobile.

Re: SubStack messes up put statement

Posted: Fri Apr 10, 2020 7:45 am
by mrcoollion
Hi Jaque
Why not just show the spinner on the card in the main stack?
True, I could just show the spinner on the card. But this way I can use the same routine on the other cards very easy. And it was for learning purposes.
be aware you can't have two stacks open simultaneously on mobile
I am working on an application that will probably only be run on Windows and might run on Linux. So not on a mobile platform. Thanks for the warning. It is something I did not know.

Regards,

Paul

Re: SubStack messes up put statement

Posted: Fri Apr 10, 2020 1:26 pm
by mrcoollion
Klaus wrote:
Thu Apr 09, 2020 4:34 pm
REALLY? :shock:
I just tested this here and did not get what I exspected!

As far as I know WINDOWSHAPE only works with images!?
You Are Correct, but it does remove the stack borders.

So here is a sample stack for those who are curious how ....
SubStack_Spinner_V001.zip
(1.55 KiB) Downloaded 274 times

Re: SubStack messes up put statement

Posted: Fri Apr 10, 2020 6:37 pm
by jacque
My method is to group the temporary control(s). When I want to display it, place the group on the card. When I'm done with it, remove the group from the card. This is very fast and uses less resources, and allows the use of the group anywhere.

Groups do not have to be placed on any card, they can exist without any visible presence.

Re: SubStack messes up put statement

Posted: Sat Apr 11, 2020 10:27 am
by mrcoollion
Thanks for the 8) tip Jacque