On startup not working
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
On startup not working
Hi all,
I have put the code attempts 1, 2 and 3 below into the master stack but without success:-
1.
on startup
go to card "template1"
end startup
2.
on startup pMode
global gRunningFromU3Drive
switch pMode
case "u3launch"
put true into gRunningFromU3Drive
break
case empty
put false into gRunningFromU3Drive
break
end switch
end startup
on startup
go to card "homepage"
go to card "template1"
end startup
3.
on startup pMode
global gRunningFromU3Drive
switch pMode
case "u3launch"
put true into gRunningFromU3Drive
break
case empty
put false into gRunningFromU3Drive
break
end switch
go to card "homepage"
go to card "template1"
end startup
Now, I'm fresh out of ideas ! Can anyone help ?
I have put the code attempts 1, 2 and 3 below into the master stack but without success:-
1.
on startup
go to card "template1"
end startup
2.
on startup pMode
global gRunningFromU3Drive
switch pMode
case "u3launch"
put true into gRunningFromU3Drive
break
case empty
put false into gRunningFromU3Drive
break
end switch
end startup
on startup
go to card "homepage"
go to card "template1"
end startup
3.
on startup pMode
global gRunningFromU3Drive
switch pMode
case "u3launch"
put true into gRunningFromU3Drive
break
case empty
put false into gRunningFromU3Drive
break
end switch
go to card "homepage"
go to card "template1"
end startup
Now, I'm fresh out of ideas ! Can anyone help ?
Re: On startup not working
Don’t use this handler. Instead use on preOpenStack and put the handler in the card script of your first card.
In 2 you seem to using “on startup” twice, consecutively. Only the first will run.
3 might run, you probably need to specify the stack that contains the desired cards.
But almost always you’re better off using on preOpenStack
PS: PLEASE use the “code” button when you insert code (the 4th one along from the “bold” button, above where you type forum message). Just select your code and click the button and it will surround it with code tags so it’s readable - thank you
In 2 you seem to using “on startup” twice, consecutively. Only the first will run.
3 might run, you probably need to specify the stack that contains the desired cards.
But almost always you’re better off using on preOpenStack
PS: PLEASE use the “code” button when you insert code (the 4th one along from the “bold” button, above where you type forum message). Just select your code and click the button and it will surround it with code tags so it’s readable - thank you
Re: On startup not working
Many thanks, Stam, that worked fine.
Re: On startup not working
"on startup" is sent when the engine/runtime gets loaded into memory.
This will only have effect in a standalone because the IDE (Livecode) will catch this message and does not pass it.
This will only have effect in a standalone because the IDE (Livecode) will catch this message and does not pass it.
Re: On startup not working
Thanks Klaus - i knew it was something like that but couldn't quite remember and couldn't check as am at work... 

Re: On startup not working
Hi,
I seem to have got myself into a real mess ! I have been trying to get an ask box to show on start up. I've tried on startup and on preopenstack on the stack and on the first page. No success, but worse, on start up, now, I get 5 instances of the first page launching, and this is with all the code I have tried commented out!
I would just love to launch and get just the one instance of the first page launched - any ideas ?
I seem to have got myself into a real mess ! I have been trying to get an ask box to show on start up. I've tried on startup and on preopenstack on the stack and on the first page. No success, but worse, on start up, now, I get 5 instances of the first page launching, and this is with all the code I have tried commented out!
I would just love to launch and get just the one instance of the first page launched - any ideas ?
Re: On startup not working
Hi CAsba,
If yes, you can prevent your EXE from starting several times, which is not possible on a Mac, add this to your STACK script:
What exactly did you script so far for the ask/answer dialog? Please post your script(s)!
Best
Klaus
sound like you are using Windows, right?CAsba wrote: ↑Thu Nov 10, 2022 2:36 pmHi,
I seem to have got myself into a real mess ! I have been trying to get an ask box to show on start up. I've tried on startup and on preopenstack on the stack and on the first page. No success, but worse, on start up, now, I get 5 instances of the first page launching, and this is with all the code I have tried commented out!
I would just love to launch and get just the one instance of the first page launched - any ideas ?
If yes, you can prevent your EXE from starting several times, which is not possible on a Mac, add this to your STACK script:
Code: Select all
on relaunch
## Nada, just a dummy handler, but does what you need!
end relaunch
Best
Klaus
Re: On startup not working
Some hints:
if "template1" is the FIRST card in your stack, then this is not neccessary, LC will always go to the first card in a stack.
This will happen so fast, that the user might see it flashing, not good.
Please decide to what card you actually want to go first!
Where on earth did you find this "ancient" code snippet? 
Do you plan to actually use this info -> gRunningFromU3Drive?
If not, just leave it out.
Code: Select all
on XXX
go to card "template1"
end XXX
Code: Select all
on XXX
go to card "homepage"
go to card "template1"
end XXX
Please decide to what card you actually want to go first!
Code: Select all
global gRunningFromU3Drive
on startup
switch pMode
case "u3launch"
put true into gRunningFromU3Drive
break
case empty
put false into gRunningFromU3Drive
break
...
end switch
end startup

Do you plan to actually use this info -> gRunningFromU3Drive?
If not, just leave it out.
Re: On startup not working
Hi Klaus, in the meantime I accidentally deleted the home page and its copy, so I've now had to revert to a project copy - lost a couple of weeks of progress there...Well, nobody said it would be easy !
Anyway, thanks for interest and help.
Anyway, thanks for interest and help.
Re: On startup not working
OUCH!
Good luck!

Good luck!
Re: On startup not working
Good news ! I managed to copy from the backup to the current by temporarily changing the stack name to copy from - and it worked. The first card in the stack is now changed however; is there a way to nominate the "first card" ?
Re: On startup not working
Sure, just set the number of your card:
Et voila, card "the one that is not the first card" is now the first card in the stack.
Code: Select all
...
set the number of cd "the one that is not the first card" to 1
...
Re: On startup not working
Thanks a lot, worked OK.
I tried the following code - commented out parts are what I've tried - to get an input from the user the first time she runs the app:
Without the line "send mouseup..." card template1 shows. That's OK.
With the line, the btn "get business name" activates before the card template1 shows.
Any ideas ?
I tried the following code - commented out parts are what I've tried - to get an input from the user the first time she runs the app:
Code: Select all
on relaunch
## Nada, just a dummy handler, but does what you need!
end relaunch
--on startup
-- go to card "template1" of stack "casba accounts"
--end startup
on preopenstack
go to card "template1" of stack "casba accounts"
send "mouseup" to btn "Get business name" of card "template1" of stack "casba accounts"
end preopenstack
--on startup
-- send "mouseup" to btn "Get business name" of card "template1" of stack "casba accounts"
--end startup
With the line, the btn "get business name" activates before the card template1 shows.
Any ideas ?
Re: On startup not working
So "casba accounts" is not the runtime stack itself but a substack of the runtime stack?
Try to add a little delay like:
If that does not work, try -> on openstack, then without the wait.
Try to add a little delay like:
Code: Select all
on preopenstack
go to card "template1" of stack "casba accounts"
## Give LC a bit time to show that card:
wait 300 millisecs with messages
send "mouseup" to btn "Get business name" of card "template1" of stack "casba accounts"
end preopenstack
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: On startup not working
I don't know anyone who has really good backup until after they suffer a loss, including yours truly
But my loss was significant, so I got thorough: in addition to nightly redundant rotating backups (portable drives are cheaper than time), I've also added Nextcloud to my workflow.
Nextcloud is a free and open collaboration toolkit that I also use to manage all my work with clients. But for myself it lets me keep my local machines in synch, with an off-site backup.
The synch alone would be great enough, having my work files and Plugins folder updated across all machines as I go. But the backup makes it even better: everything is timestamped, backed up with each save, so I can roll back to something I was working on without losing more than a few minutes work.
I pass this along so no one has to suffer at I one suffered.

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn