Using "CLS"

BlitzPlus Forums/BlitzPlus Beginners Area/Using "CLS"

Imperium(Posted 2013) [#1]
In C++ after clearing the screen (CLS) in a terminal window any new text will be drawn on the top left. The problem is that when I clear the screen and go to the next question the text appears lower than it should. How can I get the text to appear in the top left of the window? Do I need to simulate the key press for backspace? I did this in a few of my projects for C++ and it worked fine.




Floyd(Posted 2013) [#2]
I don't think this will work. Older versions of Blitz had the Locate command, to control where to Print.

But in BlitzPlus the Print command writes to standard output and Locate doesn't even exist. Print could be used for creating utilities in the style of the old command line days. Output can appear in a terminal window, or be redirected to some other tool.

For normal BlitzPlus programming you would run in Graphics mode and "print" to screen with the Text command. When BlitzPlus was being developed I wrote a fake Print command which actually used Text. This was to make it easy to port some very old code for testing.


Imperium(Posted 2013) [#3]
I see. I'm not finished but I took another stab at it and achieved the effect I wanted. :)


Floyd(Posted 2013) [#4]
Does that work for you? I tried on my Windows 7 64-bit PC. It changes the screen resolution but doesn't display anything. I had to kill it with Task Manager, then log off and back on to restore my desktop.

I suppose I could try it in compatibility mode for some older version of Windows.


Imperium(Posted 2013) [#5]
Sorry about that but try this one. The other code above was incomplete however it did work for me.


Try changing the graphics mode to "Graphics 640,480,32,1" to launch it in full screen. Also turn off the debugger before running.


Floyd(Posted 2013) [#6]
This has gotten interesting. Your new code crashes immediately with "blitzcc.exe has stopped working". If I run in debug mode there is a message about an invalid buffer handle. So I tried putting the first Cls after the Graphics command.

Now it runs but opens two windows. I never see the menu, but do see the "Make a selection" prompt.

As I recall Blitz uses some trickery to write to the front buffer, which it can't really do. I actually writes to the back buffer, and then after some very small delay copies to the front buffer. If I try
Graphics 500, 500, 0, 2

Text 200, 200 , "Is this visible?"
Delay 2000
I just get an empty window which closes after two seconds. If I add a WaitKey to the end then there is an empty window for two seconds, followed by the text appearing.

If you are writing something just for yourself then you can use whatever works on your machine. Otherwise, the standard way to do things is to always draw/write to the back buffer then Flip to make it make it visible. Everybody should be able to see the text with this code.
Graphics 500, 500, 0, 2
SetBuffer BackBuffer()

Text 200, 200 , "Is this visible?"
Flip

Delay 2000
And I would give up on the idea of mixing Text and Print. Use Text (really a graphics command) for everything.


Imperium(Posted 2013) [#7]
Understood, I will abandon this code and rewrite it.


feeble1(Posted 2013) [#8]
I would abandon the goto route as well. You will have an easier time with functions. Try tossing the menu in a loop as well and abandon input() if you can.

That being said. The program doesn't work in blitzplus so I'm guessing you're using the blitz3d compiler, they do things a little differently (but I don't know any specifics.)


Imperium(Posted 2013) [#9]
I started the program in Blitzplus but moved it to Blitz3d, sorry for not mentioning that. I wanted to see the difference how they handle code. Isn't Blitz 3d 100% compatible with Blitzplus? Although you want to avoid using certain 2d drawing functions because they will slow down your program.


xlsior(Posted 2013) [#10]
Isn't Blitz 3d 100% compatible with Blitzplus


The 2D commandset is the same and so is the overal programming framework -- the real difference is that B3D can also do 3D graphics which blitzplus can't, and Blitzplus has windows GUI commands which aren't in B3D.


feeble1(Posted 2013) [#11]
It's not something that you should really worry about though. Once it's compiled, it doesn't matter.