How to restart the program?

Blitz3D Forums/Blitz3D Programming/How to restart the program?

modmcdl(Posted 2014) [#1]
Hello, is there any way to... like close the window then re-open it from the beginning? Sort of like restarting it?

If not, is there any way to clear all of the test from the screen?

Thanks!


AngelOnFira(Posted 2014) [#2]
Ah, child you have so much to learn. The easy answer to clear the screen is the command Cls. Put it in, it will clear the text off the screen. If you are using the print command, clearing the screen will not make the next print command start at the top. To do that, use the command Locate 0,0. I will give you an example of what I am talking about.

Print "Hello"
Print "The program will clear in 2 seconds"
Delay 2000
Cls
Print "As you can see, it cleared but the"
Print "text is on the third line."
Delay 2000
Print ""
Print "I am now going to clear it again"
Delay 2000
Cls
Locate 0,0
Print "As you can see, the text is back in the first place."
Waitkey()
End


That should work, I just wrote it in here, so if you have any questions, just ask.


RemiD(Posted 2014) [#3]
If you want to simply clear the screen to be able to write text or 2d things (plot, lines, rects, ovals), you can use :
ClsColor(R%,G%,B%)
Cls()

If you want to delete all entities (camera, listener, pivots, meshes), all brushes, all textures, you can use :
Clearworld()

If you want to reinitialize the properties of the graphics window, you can use :
EndGraphics()
Goto Line (where "Line" is a label before Graphics3d(PWidth,PHeight,Colors,Mode))


modmcdl(Posted 2014) [#4]
Thank you... I was looking around the forums, and the few I happened upon said that this was impossible. Thank you.


modmcdl(Posted 2014) [#5]
Wait... the Cls command causes my program to "Not Respond"


GfK(Posted 2014) [#6]
Turn debug mode on, and/or create a graphics context with the Graphics() function.


modmcdl(Posted 2014) [#7]
ok now i get the error "Invalid Blitz2d Buffer handle


AngelOnFira(Posted 2014) [#8]
post the exact code, and you are using blitz 3d right?
also go into help>about blitz and give me the versions numbers


fox95871(Posted 2014) [#9]
My first impression was this new user was referring to loss of graphics and so on, but it seems you are very new to programming itself considering your question about the buffer. My suggestion is to start with the commands, and especially, already working examples that you can compile with no problems. I say this not because I'm an arrogant troll, but because I started programing at thirty instead of three, and starting with working examples, and studying each command, sometimes understanding only two or three a day, was the only way to go for an absolute beginner like me.


Kryzon(Posted 2014) [#10]
I'm not sure if this will work, but if it does, it's the closest that one can get to restarting the program:
;Consider your compiled blitz program as "MyProgram.exe."

ExecFile "MyProgram.exe" ;Execute its own executable.

End ;End this instance of 'MyProgram' right now.


If you want the program to know it's being run from a restart, add some sort of command line parameter:
ExecFile "MyProgram.exe -restart"

End
The command line string can be caught with CommandLine() and then you can interpret it any way you want.

If by any chance the restarted instance of the program does not have focus, you can force-focus it by making use of the SetFocus function of User32 (from this userlib DECLS).
api_SetFocus( SystemProperty( "AppHWND" ) ) ;Restore focus to my blitz program.



modmcdl(Posted 2014) [#11]
@AngelOnFira

wtf? I could have sworn I posted this under Blitz2d


modmcdl(Posted 2014) [#12]
any idea how to "move" this?