Sheerpower Logo

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.

What you will learn

  • How to read command-line parameters
  • How to identify your running process (PID, name, mode, user)
  • How to label a process with a name and comment
  • How to read and set the working directory
  • How to read OS symbols (like PATH)
  • How to check process rights
  • How to use the clipboard and set a program icon
  • How to do a simple DNS lookup

ASK/SET SYSTEM — Quick Map

  • Startup inputs — ASK SYSTEM: PARAMETER
  • Identity & diagnostics — PID, PROCESS, PROGRAM, MODE, USER
  • Process labeling — SET SYSTEM: PROCESS, ASK/SET SYSTEM: COMMENT
  • Working context — ASK/SET SYSTEM: DIRECTORY, SYMBOL 'OS:xxx'
  • Security — ASK SYSTEM: RIGHTS
  • Convenience — ASK/SET SYSTEM: CLIPBOARD, SET SYSTEM: ICON
  • Networking lookup — SYMBOL 'DNS:x.x.x.x'

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.

1. Startup Inputs

ASK SYSTEM: PARAMETER

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.

c:> myprogram.spsrc "my_file" do_it_now ... ... ask system: parameter params$ print 'All params: '; params$ print print 'file : '; element$(params$, 1, ' ') print 'option: '; element$(params$, 2, ' ')

2. System Process Identity

ASK SYSTEM: PID

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.

ASK SYSTEM: PROCESS

What it does: Returns the current operating-system process name into a string variable.

Format:

ASK SYSTEM: PROCESS str_var
  

SET SYSTEM: PROCESS

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.

ASK SYSTEM: PROGRAM

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:

ask system: program this_program$ ... ... routine check_for_new_code: private last_datetime$, change_phase$ select case change_phase$ case '' z0$ = fileinfo$(this_program$, 'revision_date') if last_datetime$ = '' then // do nothing the first time we are here last_datetime$ = z0$ exit routine end if if last_datetime$ = z0$ then exit routine // nothing changed change_phase$ = 'waiting_for_new_code' case 'waiting_for_new_code' when exception in open file temp_ch: name this_program$, lock close #temp_ch change_phase$ = 'restart' use end when case 'restart' pass noreturn: this_program$ end select end routine

ASK SYSTEM: MODE

What it does: Returns the process mode as one of these values:

  • INTERACTIVE
  • BATCH
  • NETWORK
  • OTHER

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.

ASK SYSTEM: USER

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.

3. Process Labeling

ASK SYSTEM: COMMENT

What it does: Returns the Sheerpower operating-system comment for the process.

Format:

ASK SYSTEM: COMMENT str_var
  

SET SYSTEM: COMMENT

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.

4. Working Directory Context

ASK SYSTEM: DIRECTORY

What it does: Returns the current default device and directory.

Format:

ASK SYSTEM: DIRECTORY str_var
  

SET SYSTEM: DIRECTORY

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.

ASK SYSTEM, SYMBOL 'OS:xxx': VALUE

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$
  

5. Security

ASK SYSTEM: RIGHTS

What it does: Returns a comma-separated list of the rights explicitly granted to this process.

Format:

ASK SYSTEM: RIGHTS str_var
  

6. Convenience

ASK / SET SYSTEM: CLIPBOARD

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.

SET SYSTEM: ICON

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.).

7. Networking Lookup

ASK SYSTEM, SYMBOL 'DNS:x.x.x.x': VALUE

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.

(Show/Hide Sheerpower ASK/SET SYSTEM Takeaways)
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.