QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Petr on July 15, 2018, 05:56:53 am

Title: Program ends without warnings in small screen
Post by: Petr on July 15, 2018, 05:56:53 am

Code: QB64: [Select]
  1. V& = _NEWIMAGE(10, 10, 256)
  2. DIM colors(15) AS _UNSIGNED LONG
  3. FOR a = 31 TO 16 STEP -1 '15 colors
  4.     PSET (1, 1), a
  5.     _SOURCE V&
  6.     B& = POINT(1, 1)
  7.     colors(b) = _RGB32(_RED32(B&), _GREEN32(B&), _BLUE32(B&))
  8.     _PALETTECOLOR b, colors(b)
  9.     PRINT colors(b), B&
  10.     b = b + 1
  11.     SLEEP
  12.  

soultion is bigger _newimage in begin. Is this known bug, if this is bug?

next bug:
program print nothing - but resolution is enough:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(19, 22, 256)
  2. PRINT "A"
  3.  

Title: Re: Program ends without warnings in small screen
Post by: Petr on July 15, 2018, 06:08:24 am
I found, in first souce do it PRINT, with newimage 20x20 program starts, but as show second source, A is not printed.
Title: Re: Program ends without warnings in small screen
Post by: bplus on July 15, 2018, 08:56:04 am
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(19, 22, 256)
  2. _PRINTSTRING (1, 1), "B+"
  3. SLEEP 'hit a key twice to close window
Title: Re: Program ends without warnings in small screen
Post by: Petr on July 15, 2018, 08:59:57 am
Hi Bplus. Yes, but try use it in SCREEN 0. For example if you print to virtual screen, you need not graphic screen, but _PRINTSCREEN need it.
Title: Re: Program ends without warnings in small screen
Post by: bplus on July 15, 2018, 09:03:26 am
OK I got another idea, be right back!
Title: Re: Program ends without warnings in small screen
Post by: bplus on July 15, 2018, 09:12:18 am
Didn't work.

Isn't 256 a graphics screen? specially from _NEWIMAGE
Title: Re: Program ends without warnings in small screen
Post by: Petr on July 15, 2018, 09:20:05 am
for _PRINTSTRING you need grphic screen, for _PUTIMAGE too. In case, you need print to small text screen, with PRINT, it works not. I ask why :-D Next ask is, if PRINT fail, why first program is quit. This muss be something in C level. Maybe textscreen need headers and footers, I do not know...
Title: Re: Program ends without warnings in small screen
Post by: Petr on July 15, 2018, 09:47:58 am
I do next experiments, so it works not in graphic mode only. In text mode it works.
Title: Re: Program ends without warnings in small screen
Post by: Cobalt on July 15, 2018, 11:59:05 am
so is your image(window) a text area or a graphical area? if you want text you need to use 0(zero) not 256. your first example flat out crashes on my computer. probably cause windows can not fit the title bar in a space 10 pixels wide.
if you want a text area 10 characters square then you need to use _newimage(10,10,0)

otherwise I'm going to guess that the area is just too small for the OS to use.
Title: Re: Program ends without warnings in small screen
Post by: FellippeHeitor on July 15, 2018, 01:16:19 pm
@Petr:
Your first example interestingly doesn't crash on my Windows XP machine. It probably crashes on other systems for the reasons already outlined by Cobalt above: your OS has trouble creating a window that small.

"Is this a known bug, if this is a bug", you ask? I wouldn't call it a bug especially since it works as expected on my Windows XP VM, but it definitely doesn't sound like something productive or practical. Why would you have a program screen that small? It looks like malpractice.

For the next "bug" in your original post: You create a screen that's small enough to fit a character, but then you use PRINT, which will create a new line immediately after printing. Then what happens to your expected "A" character? It gets scrolled up. It wouldn't happen if you did this:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(19, 22, 256)
  2. PRINT "A";
  3.  

Notice the semicolon (;) after the PRINT line? That'll keep the cursor from going down and creating a new blank line.

About _PRINTSTRING, it does work well on text screens but instead of pixel coordinates it takes character positions. It becomes a macro to replace a LOCATE and a PRINT:

Code: QB64: [Select]
  1. _PRINTSTRING (10, 12), "Text"
  2. 'is the same as:
  3. LOCATE 12, 10
  4. PRINT "Text"

Just notice that row/column parameters are swapped (LOCATE takes a row and a column, while _PRINTSTRING takes x, y coordinates).
Title: Re: Program ends without warnings in small screen
Post by: Petr on July 15, 2018, 05:26:57 pm
Jesus Maria, how could me escape? How could I not have noticed? Semicolon! This can not be true. :-D Thank you very much. With this practice - yeah, it's probably a stupid practice, today am i do one stupid thing and it's not going and it's not going again...  and it's still not going.... I have weaker days ... last twenty years ....: D