QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Petr on September 10, 2018, 12:28:55 pm

Title: Attempting for multiple screen get ended with a bug
Post by: Petr on September 10, 2018, 12:28:55 pm
i tried to take pictures from the screen. The behavior of the program is very strange.

As output should be a few screenshots. But it not work. WHY?

Code: QB64: [Select]
  1. t# = TIMER
  2. DO UNTIL a = 3
  3.     PRINT a ' :beep  BEEP WORK
  4.     IF TIMER > t# + 1 THEN
  5.         scr(a) = _NEWIMAGE(640, 480, 32)
  6.         e = _SCREENIMAGE
  7.         PRINT e: BEEP 'BEEP NOT WORK, SCREENIMAGE NOT WORK, PRINT NOT WORK
  8.         _PUTIMAGE , e, scr(a)
  9.         _DELAY .1
  10.         t## = TIMER
  11.         ' _FREEIMAGE e&
  12.  
  13.         BEEP 'NOT WORK
  14.     END IF
  15.     a = a + 1
  16.  
  17. FOR a = 0 TO 3
  18.     SCREEN scr(a)
  19.     SLEEP
  20.  
  21.  

I am sorry for alarm, i am IDIOT. Variable "a" is outside the loop...
Title: Re: Attempting for multiple screen get ended with a bug
Post by: SMcNeill on September 10, 2018, 12:37:14 pm
Is t# the timer, or t##?  Is this a typing goof, or deliberately two different variables?
Title: Re: Attempting for multiple screen get ended with a bug
Post by: Petr on September 10, 2018, 12:42:14 pm
Steve, i found it now.... i look to it but see it not...
Title: Re: Attempting for multiple screen get ended with a bug
Post by: FellippeHeitor on September 10, 2018, 12:42:56 pm
Maybe simplify it:

Code: QB64: [Select]
  1. DIM scr(1 TO 3) AS LONG
  2. FOR i = 1 TO 3
  3.     PRINT i
  4.     scr(i) = _SCREENIMAGE
  5.     _DELAY 1
  6.  
  7. FOR i = 1 TO 3
  8.     PRINT "Press a key..."
  9.     a$ = INPUT$(1)
  10.     SCREEN scr(i)
  11.     PRINT "Image #"; i
  12.  
Title: Re: Attempting for multiple screen get ended with a bug
Post by: FellippeHeitor on September 10, 2018, 12:43:38 pm
Steve, i found it now.... i look to it but see it not...

BTW: OPTION _EXPLICIT at the top of your program would have saved you some debugging here.
Title: Re: Attempting for multiple screen get ended with a bug
Post by: Petr on September 10, 2018, 12:46:33 pm
Yes, there are 2 errors... Variable "a" muss be in IF...THEN condition and variable t is wrong, muss be double # type  on all places... thank you!
Title: Re: Attempting for multiple screen get ended with a bug
Post by: TerryRitchie on September 10, 2018, 12:55:23 pm
Steve, i found it now.... i look to it but see it not...
OPTION _EXPLICIT at the top of your program would have saved you some debugging here.

OPTION _EXPLICIT is the only way to go when dealing with code greater than 100 lines. It has saved me many hours of frustration.