Author Topic: any help please?  (Read 4932 times)

0 Members and 1 Guest are viewing this topic.

Offline sarmad

  • Newbie
  • Posts: 4
    • View Profile
any help please?
« on: September 19, 2021, 06:27:03 am »
hello every one
am just a bigenner in qb64  i try to make a program that print numbers from 1 to 40 and draw a circle .. very simple but when i run that i get the numbers from 13 to 40 with no scrollable screen and get the circle inside .. when i use $console:only with aame program i get no thing as shown in pictures.. how can i combine between 1 to 40 scrollable window and the circle in one o/p window?

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: any help please?
« Reply #1 on: September 19, 2021, 06:50:28 am »
I am no expert, when it comes to QB64, but from using 'help' > Keyword Index > SCREEN (statement)... Screen 12, depending on the size of font, will either have 30 or 60 lines of text. The default setting seems to be 30 lines. So, in a nutshell, once "i" has passed 30, the earlier displays of "i" have scrolled off the top of the screen. Of course, this happens quite quickly, and will 'appear' to 'start' at '13'.

Code: QB64: [Select]
  1. CIRCLE (200, 300), 50, 6
  2. FOR i = 1 TO 40
  3.     PRINT i
  4.     _DELAY 0.25
  5.  

Run this example. The delay will demonstrate what has happened to the first 12 lines of display.

I hope this helps.

As for your 'scrolling' issue... I'm afraid I may not be your best choice in answers... My simplest answer is, 'I do not know'.
But there are many more people on this forum that are much more clever than myself... It will not take long to get your answer.

J
« Last Edit: September 19, 2021, 06:58:09 am by johnno56 »
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: any help please?
« Reply #2 on: September 19, 2021, 10:48:26 am »
Yes that's how I see it: for scrolling use console, no graphics. For graphics use Screen, no scrolling.

You could probable fake scrolling on a screen with graphics but it'd be some effort.
« Last Edit: September 19, 2021, 10:54:16 am by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: any help please?
« Reply #3 on: September 19, 2021, 01:04:02 pm »
Yes that's how I see it: for scrolling use console, no graphics. For graphics use Screen, no scrolling.

You could probable fake scrolling on a screen with graphics but it'd be some effort.

Even the console scrolls after a certain number of lines; it doesn’t store them all in memory infinity.

Getting all the data you need to display on the screen all at once can sometimes take a good bit of effort by a programmer.  What the OP talks about here sounds like a homework problem to help sort that issue out, with the solution being to use commas, print using, tab, or some other method to properly form multiple columns and display a graphic together.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: any help please?
« Reply #4 on: September 19, 2021, 02:52:40 pm »
Get a B+
  [ You are not allowed to view this attachment ]  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: any help please?
« Reply #5 on: September 19, 2021, 03:39:41 pm »
Another B+
  [ You are not allowed to view this attachment ]  

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: any help please?
« Reply #6 on: September 19, 2021, 05:23:06 pm »
WHAT!! No blue?!?!  lol...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: any help please?
« Reply #7 on: September 19, 2021, 08:16:57 pm »
OK blue
  [ You are not allowed to view this attachment ]  

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: any help please?
« Reply #8 on: September 19, 2021, 09:28:52 pm »
I generally find it easiest to put whatever you want to scroll into an array, then use a display loop with an offset value controlled by the mousewheel.

If I understand the problem right, you're trying to do something like this...
Code: QB64: [Select]
  1. 'Circle and scroll
  2. D& = _NEWIMAGE(600, 400, 32)
  3. REDIM  A(40) AS INTEGER
  4. FOR x = 1 TO 40
  5.     A(x) = x
  6. offset = 0
  7. rows = INT(_HEIGHT(D&) / 16) - 2
  8.  
  9.     CLS
  10.     CIRCLE (300, 100), 75, &HFFFF0000
  11.     FOR k = 1 TO rows
  12.         PRINT A(k + offset)
  13.     NEXT k
  14.         offset = offset + SGN(_MOUSEWHEEL)
  15.         IF offset < 0 THEN offset = 0
  16.         IF offset + rows > UBOUND(A) THEN offset = UBOUND(A) - rows
  17.     WEND
  18.     _DISPLAY 'eliminate screen flicker
  19.     _LIMIT 30
  20. LOOP UNTIL _KEYDOWN(27) 'Esc to end
  21.  
« Last Edit: September 19, 2021, 09:35:35 pm by OldMoses »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: any help please?
« Reply #9 on: September 19, 2021, 09:44:32 pm »
Oh heck I thought he wanted to do this:
Code: QB64: [Select]
  1. 'Circle and scroll
  2. D& = _NewImage(600, 400, 32)
  3. For x = 1 To 40
  4.     A(x) = x
  5. offset = 0
  6. rows = Int(_Height(D&) / 16) - 2
  7.  
  8.     Cls
  9.     Circle (300, 300 - offset * 16), 75, &HFFFF0000
  10.     For k = 1 To rows
  11.         Print A(k + offset)
  12.     Next k
  13.         offset = offset + Sgn(_MouseWheel)
  14.         If offset < 0 Then offset = 0
  15.         If offset + rows > UBound(A) Then offset = UBound(A) - rows
  16.     Wend
  17.     _Display 'eliminate screen flicker
  18.     _Limit 30
  19. Loop Until _KeyDown(27) 'Esc to end
  20.  
  21.  
  22.  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: any help please?
« Reply #10 on: September 19, 2021, 09:48:47 pm »
For this type issue, I’d just keep it very simple:

SCREEN _NEWIMAGE(640,480,32)

FOR I = 1 TO 40 STEP 2
   PRINT USING “####          ####”; I, I +1
NEXT

CIRCLE (300, 300), 100, _RGB32(255, 255, 0)



2 Simple columns of data.  One circle. 

It’s not going to get much simpler than that.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: any help please?
« Reply #11 on: September 19, 2021, 10:18:45 pm »
Actually we can create a whole image to scroll up and down:
Code: QB64: [Select]
  1. 'Circle and scroll
  2. D& = _NewImage(600, 400, 32)
  3. For x = 1 To 40
  4.     A(x) = x
  5. offset = 0
  6. rows = Int(_Height(D&) / 16) - 2
  7. s& = _NewImage(600, 672)
  8. For i = 1 To 40
  9.     If Rnd < .5 Then
  10.         Circle (Rnd * 600, Rnd * 672), Rnd * 50 + 10, _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
  11.     Else
  12.         Line (Rnd * 600, Rnd * 672)-Step(Rnd * 100, Rnd * 100), _RGB32(Rnd * 255, Rnd * 255, Rnd * 255), B
  13.     End If
  14.     Cls
  15.     _PutImage , s&, 0, (0, offset * 16)-Step(600, 400)
  16.     For k = 1 To rows
  17.         Print A(k + offset)
  18.     Next k
  19.         offset = offset + Sgn(_MouseWheel)
  20.         If offset < 0 Then offset = 0
  21.         If offset + rows > UBound(A) Then offset = UBound(A) - rows
  22.     Wend
  23.     _Display 'eliminate screen flicker
  24.     _Limit 30
  25. Loop Until _KeyDown(27) 'Esc to end
  26.  
  27.  
  28.  

I didn't think it this easy!
« Last Edit: September 19, 2021, 10:25:30 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: any help please?
« Reply #12 on: September 19, 2021, 10:22:54 pm »
Quote
It’s not going to get much simpler than that.

Here is simpler:
Code: QB64: [Select]
  1. Circle (200, 300), 50, 6
  2. For i = 1 To 40
  3.     Print i,
  4.  

Just 1 char more than original.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: any help please?
« Reply #13 on: September 19, 2021, 10:48:48 pm »
How about scrolling down a moving graphic image?
Code: QB64: [Select]
  1. _Title "Scroll Moving Image" 'b+ 2021-09-19
  2. D& = _NewImage(600, 400, 32)
  3. For x = 1 To 40
  4.     A(x) = x
  5. offset = 0
  6. rows = Int(_Height(D&) / 16) - 2
  7. s& = _NewImage(600, 672)
  8. ca = _Pi(2 / 40)
  9. start = _Pi(3 / 2)
  10. rstart = 12
  11. af = 6
  12.     _Dest s& ' update image
  13.     Color &HFFBBBBFF, &H00330044 ' transparent background for letters
  14.     Cls
  15.     r = rstart
  16.     i = 1
  17.     For a = start To start + _Pi(2) Step ca
  18.         _PrintString (300 + r * Cos(af * a) - 8, 300 + r * Sin(af * a) - 8), Right$(Str$(i), 2)
  19.         i = i + 1
  20.         r = r + 5
  21.     Next
  22.     Circle (300, 300), 216
  23.     af = af - .005
  24.  
  25.     _Dest 0 ' update view screen
  26.     Cls
  27.     _PutImage , s&, 0, (0, offset * 16)-Step(600, 400)
  28.     For k = 1 To rows
  29.         Print A(k + offset)
  30.     Next k
  31.         offset = offset + Sgn(_MouseWheel)
  32.         If offset < 0 Then offset = 0
  33.         If offset + rows > UBound(a) Then offset = UBound(a) - rows
  34.     Wend
  35.     _Display 'eliminate screen flicker
  36.     _Limit 30
  37. Loop Until _KeyDown(27) 'Esc to end
  38.  
  39.  
  40.  

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: any help please?
« Reply #14 on: September 20, 2021, 01:04:52 am »
OK blue

Nice. I even like the spiral effect... Cool...
Logic is the beginning of wisdom.