Page 1 of 2

Program start

Posted: Wednesday 23rd August 2017 3:09pm
by cogier
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


Re: Program start

Posted: Wednesday 23rd August 2017 3:52pm
by jornmo
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).

Re: Program start

Posted: Thursday 24th August 2017 12:34pm
by cogier
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 506 times

Re: Program start

Posted: Thursday 24th August 2017 1:11pm
by jornmo
Line 30?
Public Sub BuildForm()                        'To add items to the Form
I do still not follow you friend :)

Re: Program start

Posted: Friday 25th August 2017 6:33am
by cogier
Sorry. It's the last line in
Public Sub Form_Open()
hTimer1.trigger

Re: Program start

Posted: Friday 25th August 2017 8:05am
by jornmo
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

Re: Program start

Posted: Friday 25th August 2017 1:29pm
by cogier
Opps! :o

Sorry I uploaded an earlier version :roll:

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

Re: Program start

Posted: Saturday 26th August 2017 8:05pm
by jornmo
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 487 times

Re: Program start

Posted: Sunday 27th August 2017 1:19pm
by cogier
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.

Re: Program start

Posted: Sunday 27th August 2017 4:48pm
by jornmo
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 :)