A console application is a computer program designed to be used via a text-only computer interface.
A text-only interface could be a text terminal, the command line interface of the operating systems (Unix, DOS, etc.) or the text-based interface included with some Graphical User Interface (GUI) operating systems, such as the Win32 console in Microsoft Windows.
A user typically interacts with a console application using only a keyboard and display screen, as opposed to GUI applications, which normally require the use of a mouse or other pointing device.
Many console applications such as command line interpreters are command line tools, but numerous Text User Interface (TUI) programs also exist.
As the speed and ease-of-use of GUI applications have improved over time, the use of console applications has greatly diminished, but not disappeared. Some users simply prefer console based applications, while some organizations still rely on existing console applications to handle key data processing tasks.
Let's look at the structure and function of some of the commands that make up the program.
First, you will note some comments at the top of the file. Comments in ebasic can be indicated by:
Comments are used to document things you might otherwise forget or just to explaine something.
You determine the comment - just note that you will for get things so comments really help.
Anything noted as a comment in the source code is ignored by the compiler.
The next line is the '$use "wsock32.dll" directive. This is a pre-processor command that tells the Linker pass of the compiler to import this library.
The next items are the TYPE declarations or UDT's (User Defined Type).
They define grouped data storage. The members of a UDT can be any built-in or user defined type. Use the DEF statement for defining the individual data members.
You must end the definition with the ENDTYPE statement.
Next you see a group of declare statements.
These statements tell the compiler that you want to declare a local, external, or import function and its parameters.
In this case we are telling the compiler that we will be using several external subroutines.
Next we define a couple of Constants. A constant is a special tag that assignes a name to a variable. This makes it eaiser for us to remember items as opposed to values.
Next we define a couple of variables and their type so that when we reference them in the program the compiler knows what we are talking about.
Next we issue the OPENCONSOLE command - this instructs the compiler to build our console (DOS) window.
Now we contact the subroutine StartWinSock().
This routine will return a non-zero value if successful.
If the IF statement evaluates to 'TRUE' (not zero) several subroutines within our program are called to produce our output.
Note that the ENDIF closes the IF command.
Next you see:
This code keeps the CONSOLE open until we hit a key. This will allow the output from the subroutines to stay on the screen so that we can read it.
This has been a simple example of a console program. Console programs tend to be for a specific purpose. You will need to define your purpose and build your console application as needed.