Newbie question-How to clear screen

I used to write programs along time ago in BASIC and now I am re-learning how to write for Xojo.

In the old days to show the user a new screen of the program, a “clear screen” command was given.

How do I do the same thing in Xojo (get rid of a screen of info and start/show a new screen of info)?

Thanks for the help!

Welcome … join the club.
I would recommend you to read the book “Introduction Programming in Xojo

David,

to clear the screen, you have to have things to remove (even in the old time).

So, start putting controls in the screen, eventually add data in them, then:

a. If you want to “hide” the controls from the screen, set their Visible property to False,

b. if you want to clear the data from the control they reside in, it depends on the control. For example:

TextEdit Controls (TextArea and TextField): set the .Text properti to “” (empty)
ListBox, PopupMenu, etc.: use .DeleteAllRows

At last: if all of the above is like Chaldean * words to you, follow Joost excellent advice.

  • Eventually, it can be chineese to you; but since I do not know if you talk Chineede (Traditional or Mandarin)… ;-:slight_smile:

This today is achieved by closing windows. But depends what kind of application you want to do. Sometimes it can be better done by using ContainerControls.

[quote=211665:@David Byrum]I used to write programs along time ago in BASIC and now I am re-learning how to write for Xojo.

In the old days to show the user a new screen of the program, a “clear screen” command was given.

How do I do the same thing in Xojo (get rid of a screen of info and start/show a new screen of info)?

Thanks for the help![/quote]
What are you doing? Console apps? Answers will depend on info like this.

He was thinking of the command “HOME” in Applesoft Basic, which clears the screen.

You need to think completely different.

Welcome to Xojo. I think you’ll find this forum really helpful. Since you are new to Xojo I’d recommend the Introduction to Xojo book recommended above and looking through the copious amounts of example programs.

If you are the type that learns through watching others, I have over 60 hours of Xojo training videos at http://xojo.bkeeney.com/XojoTraining/. Subscribers have access to over 200 videos (most with project files) and two complete start-to-finish desktop apps and one start-to-finish web application. I also have about 10 hours of iOS video.

or CLS or CLEAR

Those had meaning in console based languages such as QBASIC, MBASIC where the only output device was a “terminal” but in todays modern GUI based world those specific commands have no place. As others have indicated, it depends on what is on the screen.

Controls can be made VISIBLE or not (control.visible=false)
Graphic areas such as CANVAS or PICTURE can be cleared using ClearRect or filling them with a specific color
Text Controls such as TextEdit and TextArea can be cleared by removing their content (textEdit1.text="")

So your question has many answers, with the specific answer depending on the specific circumstance

Actually, the old text-based interface is more like a TextArea that would use a fixed width font. Very very much like the Command Line Terminal in Mac and Linux, or the Command Prompt in Windows. In a console app, ESC[2J used to work for clearing the screen.

In a TextArea Home, Cls or Clear would be obtained with TextArea.Text = “”.

I have played in the past with older QuickBasic code, running in Text mode in a TextArea. It works for a command line interface emulation.

Not sure the OP knows exactly what he wants to achieve.

Or then of course there is my RetroBasic written in XOJO :slight_smile:

RetroBasic Project

Thanks to all who responded to my “Newbie” question. I have been traveling for the past few weeks and was not able to respond sooner.

To:

Joost R - Yes I have that book and am slowly making my way through it. Thanks for the welcome :wink:

Emile S - Thanks for the nice tutorial! You have helped to adjust my thinking from the old days of BASIC programming!

Michel B - Thank you too for the explanation for todays method compared to the old BASIC method. To help myself learn the new environment I am taking an old program that I wrote in Commodore BASIC that allowed a user to enter their Birthday, a friends Birthday, choose a Star to visit and what fraction of the speed of light that their spaceship would be traveling. The program would then clear the screen and “print” the to a new screen the age of the traveler and the age of the person who stayed behind on Earth. Since time is relative to the speed that one is traveling, the traveler will age slower than the person who remained on Earth. It is a good simulation to help students get a bit of grip on Relativity, and to help me relearn how to program! I’m not sure if this is a “console app” or not. Is it?

Detlev K - Yes you are correct!

Bob K - Thanks for the link to the training videos - I will be taking advantage of them!

Dave S - Thanks for the added clarification of ways to show/hide information in XOJO.

Michel B - I do know what I want to achieve, see the answer that I wrote to you above, otherwise I would not have asked a specific question :slight_smile:

Dave S - I will take a look at your RetroBasic Project to see how the “old” BASIC relates to the newer languages like XOJO.

Thanks again to all of you who took the time to respond and to offer advice and help. I appreciate your time and efforts very much and I’m sure that I will be back with more questions in the future. Hopefully at some point in time I will then be able to help others too!

Some general ideas…

You could do this on a console-like app using shell commands (for example); and it would look very similar to the old days. The application would have to interact with the shell object and consume the information the user enters.

You could do this “emulating” the old screen using a text area and parsing the information entered on it (like Michel referenced).

You could do it with “forms” or “objects” similar to what you would see on a website today (for example). As an example of this last one; you would have a Window where the user and friend’s name could be entered on text fields; the birth dates could be entered on drop down fields (month, day, year), the star could be chosen via another drop down field, and the fraction of the speed of light could be yet another drop down field. The drop down fields are popup menu objects or combo box objects (in Xojo). The Window could have a button you press to calculate the ages of the user and friend once the trip is completed. That can be displayed on a text field on the Window or as a message dialog. This is akin to a Hello World application on the VB6 days. There are many many other ways of doing the same, and more visually appealing.

The closest to the old line oriented Basic is indeed a Console app. But yet, it would be much more limited than Commodore Basic did. And besides, you want to move to a more modern app, don’t you ?

You can get to a very close equivalent of your older program by dropping a TextArea from the library on the right to the window.

A TextArea works line by line as well, and you will find the same kind of line by line approach.

To mimic the way an old Basic works, place the code in the Open event of the TextArea, and direct commands to “Me”, which means the TextArea itself.

The Print command will be replaced by Me.AppendText, as in

Me.AppendText "Hello Word" + EndOfLine

Note the EndOfLine after the sentence, which was, if I remember right, NewLine. What it does is put the cursor on the next line.

The CLS command you are looking for to clear the screen is obtained by setting the Text property of the TextArea to “”.

Me.Text = ""

That will enable you to run some of the age old programs you got.

However, be aware that this is an emulation that is only mentioned as an exercise. It lets you play with a control: TextArea, with an event: Open, and use a property of the control Text.

There is much, much more to Xojo and you will soon create extraordinary programs, if you apply yourself to discovering it. I strongly suggest you start by reading Introduction to Programming, available for download here https://xojo.com/learn/ It will take you step by step through all the basic concepts of modern programming. Fear not, what you already know will be of use.