Skip to content

Class Program

Kristian Virtanen edited this page Oct 14, 2024 · 4 revisions

Description:

Provides methods and properties related to the execution of the program, including command-line argument handling delays, and termination.

Example codes:

Methods:

  • Program.ArgumentCount
  • Gets the number of command-line arguments passed to the program (excluding the program name).

  • Program.Directory
  • Gets the directory where the program is being executed.

  • Program.Delay(milliSeconds)
  • Delays the program execution for the specified number of milliseconds.
  • Unlike Program.Sleep(seconds), Delay can't be interrupted

  • Program.End()
  • Ends the program execution immediately.

  • Program.GetArgument(index)
  • Retrieves the command-line argument at the specified index.

  • Program.Sleep(seconds)
  • Delays the program execution for the specified number of milliseconds.
  • Unlike Program.Delay(milliSeconds), Sleep can be interrupted

Top

Example code in SmallBasicOE:

Program.Delay(3000) '  Waits 3 seconds even if key is pressed.
Program.Sleep(3) '  Waits 3 seconds, but can be interrupted by keypress.
TextWindow.WriteLine(Program.ArgumentCount) '  Writes the amount of parameters program received.
TextWindow.WriteLine(Program.Directory) ' Writes the program directory path.
TextWindow.WriteLine(Program.GetArgument(1)) '  Writes first argument, if received.
Program.End() '  Closes the program

Top

Example code in C#:

namespace SmallBasicOpenEditionDll
{
    class Program2
    {
        static void Main()
        {
            Program.Delay(3000); // Waits 3 seconds even if key is pressed.
            Program.Sleep(3); // Waits 3 seconds, but can be interrupted by keypress.
            TextWindow.WriteLine(Program.ArgumentCount); // Writes the amount of parameters program received.
            TextWindow.WriteLine(Program.Directory);  // Writes the program directory path.
            TextWindow.WriteLine(Program.GetArgument(1)); // Writes first argument, if received.
            Program.End(); // Closes the program
        }
    }
}

Top

Clone this wiki locally