Author Topic: Attempting for multiple screen get ended with a bug  (Read 2137 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Attempting for multiple screen get ended with a bug
« 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...
« Last Edit: September 10, 2018, 12:41:14 pm by Petr »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Attempting for multiple screen get ended with a bug
« Reply #1 on: September 10, 2018, 12:37:14 pm »
Is t# the timer, or t##?  Is this a typing goof, or deliberately two different variables?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Attempting for multiple screen get ended with a bug
« Reply #2 on: September 10, 2018, 12:42:14 pm »
Steve, i found it now.... i look to it but see it not...

FellippeHeitor

  • Guest
Re: Attempting for multiple screen get ended with a bug
« Reply #3 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.  

FellippeHeitor

  • Guest
Re: Attempting for multiple screen get ended with a bug
« Reply #4 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.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Attempting for multiple screen get ended with a bug
« Reply #5 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!

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Attempting for multiple screen get ended with a bug
« Reply #6 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.
In order to understand recursion, one must first understand recursion.