Program start

Post your Gambas programming questions here.
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Program start

Post 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

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

Re: Program start

Post 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).
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post 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 492 times
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post by jornmo »

Line 30?
Public Sub BuildForm()                        'To add items to the Form
I do still not follow you friend :)
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier »

Sorry. It's the last line in
Public Sub Form_Open()
hTimer1.trigger
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post 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
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post by cogier »

Opps! :o

Sorry I uploaded an earlier version :roll:

Please see attached..
15PuzzleGame.tar
(351 KiB) Downloaded 466 times
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post 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 474 times
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Program start

Post 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.
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Program start

Post 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 :)
Post Reply