Reduce Online Time With Command Files and Scripts
Many types of searches can require long online sessions - for example, searching for multiple accession or Registry Numbers, or very lengthy search strategies. These types of searches are also prone to typing errors, which can lead to even longer online time or incorrect results. With STN Express, you can create command files and scripts off-line that can help reduce online time and can be reused for similar searches/strategies. What is a Command File?
A Command File is a list of STN (or other online host) commands in a text file. The STN Express Command Window can read the list of commands from the file and send the commands to STN.
What is a script?
A script is a Command File that uses features of the STN Express script language. As shown in the example below, the script language includes features for reading files, repeating STN commands, and making decisions.
Assumptions
- This example uses STN Express for Windows. The principles are the same for STN Express for Macintosh.
- STN Express 4.0 or higher is installed in C:\Stnexp.
To illustrate how helpful a script can be, suppose you have a list of CA accession numbers (CANs) and want to display their records in the CAplus file on STN.
Step A: Create a data file
Create a text file of CA accession numbers. Here is a sample file:
102:123456
111:100004
90:1
124:99999
Create the file using Notepad or a similar text editor. (You can use Microsoft Word or other word processor as long as you save the file as an ASCII text file. Do not save it as a Word document.) When you create the file, store it in the Uscripts folder which is in your STN Express installation folder. In particular, if you want to use the script shown in Step B as-written, you will want to name the file of CANs cans.txt and save it in C:\Stnexp\Uscripts\.
Step B: Write the script
Create the script that reads the file of accession numbers you created in Step A. Here is the script:
\* Enter the STN file of choice.
=> file caplus
\* Open the file that contains the
\* CA Accession Numbers (CANs).
open <cans.txt>
\* process all the CANs
@start
\* Read 1st/next CAN.
read _an
\* Stop if end of CAN file.
if (_$filerror = 0) begin
=> dis _an all
goto @start
end
\* Close the file that contains Cans
close
- Lines that begin with \* are comment lines to help you remember what the script is doing.
- Words and lines shown in blue are part of the script language.
- Words shown in red are STN commands.
You can create this script with a text editor such as Notepad, or you can create it in STN Express. Make sure you store the script in C:\Stnexp\Uscripts and that it has an extension of .sc. In this example, the script file is named candisp.sc.
To create the file in STN Express, click the Query menu and then select Prepare Command File. Then click New. In the STNEdit window, type the script above, or copy it from this page and paste it into STNEdit. After you are finished, go to the File menu and select Save As. Notice that Express automatically puts the .sc extension on the name. Type in the name and then click Save. Then click the File menu and Exit.
Whether you create the command (script) file in Notepad, STN Express, or some other text editor, make sure the file specified in the 5th line of the script (in this example, cans.txt) is the name of the file you created in Step A.
Finally, to make sure your script has no obvious errors, go into STN Express and click Query, then Check Command File. Click the name of your script and then click Check Script. If it is OK, you will get the message "No errors were detected in candisp.sc". Click OK.
Step C: Run the script
Log on to STN as usual. If you log on and are not prompted to capture the session, then go to the Results menu, click Capture Session, and specify the name of your transcript.
To run the script, click Query | Run Command File. Then click the name of the script you created in Step B (candisp.sc). Click Open. The script will send commands to STN to enter file CAplus, then read your CA accession numbers and display the information associated with each one.
Type "log y" and hit the Return key, or click the Logoff button to log off.
Step D: Check your results
To look at the captured results, click Results | Browse Transcript. Click the name you specified in Step C and then click Open. Browse the results on your screen or print the transcript (File | Print).
