Program start

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Program start

Post by cogier » Wednesday 23rd August 2017 3:09pm

Has anybody go a way to start a Sub without coming back to Sub Form_Open(). I can do it with a Timer, as below, but it seems to me there should be an easier way.

Public Sub Form_Open()

  Timer1.Trigger

End

Public Sub Second()

  Print "Hello world!"

End

Public Sub Timer1_Timer()

  Second

End


User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Wednesday 23rd August 2017 3:52pm

Can you elaborate on what it is you want to accomplish? Why is it that Form_Open() is not sufficient? You could call it from a different class or module if you make it public.

You can also call it at the constructor, a.k.a. _new() (probably _init() and _ready() as well).

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Thursday 24th August 2017 12:34pm

OK here is what I am working on. If you Rem out line 30 and run the program you will see the issue.
15PuzzleGame.tar
(130.5 KiB) Downloaded 7 times

User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Thursday 24th August 2017 1:11pm

Line 30?
Public Sub BuildForm()                        'To add items to the Form
I do still not follow you friend :)

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Friday 25th August 2017 6:33am

Sorry. It's the last line in
Public Sub Form_Open()
hTimer1.trigger

User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Friday 25th August 2017 8:05am

Have you uploaded the same version? The code you gave me calls BuildForm, which in turn calls AddTimer which again calles hTimer.Start...

Anyway... I still do not know why you want to avoid this? Can you tell me like I am five years old, haha :D

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Friday 25th August 2017 1:29pm

Opps! :o

Sorry I uploaded an earlier version :roll:

Please see attached..
15PuzzleGame.tar
(351 KiB) Downloaded 5 times

User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Saturday 26th August 2017 8:05pm

I did not fully understand your code, but I tried to make a variant to what it seems you try to achieve:
JE15PuzzleGame-0.0.1.tar.gz
(11.59 KiB) Downloaded 4 times

User avatar
cogier
Site Admin
Posts: 89
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier » Sunday 27th August 2017 1:19pm

I had a look at your code which works as I would expect. I just can't work out why mine needs a 'Trigger' to display.

User avatar
jornmo
Site Admin
Posts: 112
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo » Sunday 27th August 2017 4:48pm

I added this code into the top of your RebuildForm sub:
Debug "Rebuilding form", hPlayAreaPanel.W, hPlayAreaPanel.H
and it says you panel is 8x8. That's probably the problem. Now to find out why it does not fit the FMain's proportions :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest