|
Ask/SET System Information |
Many programs need to know a little bit about the computer they are
running on — things like who is signed in, what folder the program
started in, or what name the operating system is using for the process.
Sheerpower makes this easy with a set of ASK SYSTEM
and SET SYSTEM statements.
These statements let your program safely ask questions about its surroundings, or make small changes such as setting a process name, changing the working folder, or setting a window icon. You do not need to call external tools or write platform-specific code — Sheerpower handles those details for you.
How this is organized: Each section matches a common need — reading startup inputs, identifying the process, labeling it, finding files, checking rights, or doing quick lookups. This makes the tutorial easier to scan when you are looking for one specific tool.
What it does: Returns one command-line parameter (the part after the program name) into a string variable. Up to 8 parameters are returned as a space-separated list.
Format:
ASK SYSTEM: PARAMETER str_var
When to use it: When you want your program to accept a filename, an option, or a simple setting from the command line.
What it does: Returns the system process ID (PID) of the current process into a string variable.
Format:
ASK SYSTEM: PID str_var
When to use it: When writing logs or audit records so you can tell which running instance produced the output.
What it does: Returns the current operating-system process name into a string variable.
Format:
ASK SYSTEM: PROCESS str_var
What it does: Changes the operating-system process name.
Format:
SET SYSTEM: PROCESS str_expr
When to use it: When you want a clear name to show up in system tools while the program is doing a specific job.
What it does: Returns the full file specification of the running program.
Format:
ASK SYSTEM: PROGRAM str_var
When to use it: When the program needs to check its own revision date so it can automatically restart itself:
What it does: Returns the process mode as one of these values:
Format:
ASK SYSTEM: MODE str_var
When to use it: When you want different behavior depending on whether the program is running in a batch job, a network service, or an interactive session.
What it does: Returns the operating-system user name or ID for the current user.
Format:
ASK SYSTEM: USER str_var
When to use it: When you want user-aware logging, per-user folders, or audit trails.
What it does: Returns the Sheerpower operating-system comment for the process.
Format:
ASK SYSTEM: COMMENT str_var
What it does: Sets the Sheerpower operating-system comment for the process.
Format:
SET SYSTEM: COMMENT str_expr
When to use it: When you want a short "what this is doing right now" label that can show up in system tooling.
What it does: Returns the current default device and directory.
Format:
ASK SYSTEM: DIRECTORY str_var
What it does: Sets the default device and directory.
Format:
SET SYSTEM: DIRECTORY str_expr
Tip: Save the old directory first, then restore it before exiting if you are changing directories temporarily.
What it does: Reads an operating-system symbol value. On Windows, this maps to the command window environment.
Format:
ASK SYSTEM, SYMBOL 'OS:xxx': VALUE str_var
Example: Read the PATH environment value.
ask system, symbol 'os:path': value mypath$ print 'The path value is: '; mypath$
What it does: Returns a comma-separated list of the rights explicitly granted to this process.
Format:
ASK SYSTEM: RIGHTS str_var
What it does: Gets and stores clipboard text.
Format:
ASK SYSTEM: CLIPBOARD str_var SET SYSTEM: CLIPBOARD str_expr
When to use it: When you want quick copy/paste between Sheerpower scripts and other tools.
What it does: Sets the process or application icon.
Format:
SET SYSTEM: ICON filename$ // filename$ must be a fully-qualified file path to an .ico file
When to use it: When you want your program to show a custom icon in the OS UI (task bar, window chrome, process list, etc.).
What it does: Returns the DNS translation value of "x.x.x.x" into a string variable. The "x.x.x.x" can be an IP address or a URL.
Format:
ASK SYSTEM, SYMBOL 'DNS:x.x.x.x': VALUE str$
Examples:
ask system, symbol 'dns:0.0.0.0': value x$ print 'Your computer name is: '; x$
ask system, symbol 'dns:www.cnn.com': value x$ print 'The IP address is: '; x$
When to use it: When you need a quick "can I resolve this?" check, or you want to confirm a host is reachable by name or address.
ASK SYSTEM: PARAMETER to read command-line arguments.
PID, PROCESS, PROGRAM,
MODE, and USER.
SET SYSTEM: PROCESS and
ASK/SET SYSTEM: COMMENT make running programs easier
to identify in system tools and logs.
ASK/SET SYSTEM: DIRECTORY and
SYMBOL 'OS:xxx'.
ASK SYSTEM: RIGHTS, allowing programs to inspect their
granted privileges.
ASK/SET SYSTEM: CLIPBOARD and
SET SYSTEM: ICON.
SYMBOL 'DNS:x.x.x.x' without writing networking code.
|
Hide Description
|
|
|
Enter or modify the code below, and then click on RUN |
|
Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use. |