Back

Spartan Script Language

You can automate many repetitive tasks on your PC using the Spartan script language. To create a script, right click on any empty cell and select "New Script". You can also start a new script by selecting "New Text Clip" and then typing [[Script]] on the first line. Subsequent lines are the commands for the script...

[[Script]]
Command 1
Command 2
Etc.

To run a script, you just click on its cell.


You can leave remarks in your script by prefacing them with the apostrophe '

[[Script]]
Command 1 'This is a remark
Command 2
'-------This whole line is a remark
Command 3
Etc.


Text must be enclosed in quotation marks.

[[Script]]
Paste "Fred said Hello"


Spartan checks your script as you type. Usually this is helpful but it can be annoying. You can turn it on and off from the Clip Edit menu.
If, while writing a script, you cannot remember the command you want, press F1 or select "Script Helper" from the menu. Spartan lists all the elements of the language together with a short description of each. Click on any element to paste it into your script.
Whenever a clip is created by a script, it is added to both the yellow area and the clipboard history sheet. To paste clips that have been created use the PasteClip or PasteClipsFrom commands. The clip identifiers are Z1 to Z25 for the yellow area and V1 to V533 for the Clipboard History sheet. Use the yellow area if you are handling 25 or fewer clips, and the History sheet for more. The maximum number that can be handled in one script is 533.
Leave remarks in your scripts and always indent commands within Loops and If conditions. Indenting is not necessary for a script to run but it makes editing and spotting problems very easy. Below is a script which copies addresses like these..

3 Brookside Court
Prestbury Road
Macclesfield
Cheshire
SK9 3BR

14 Grim Lane
Bollington
Cheshire
SK4 2RF

from Word and pastes them into Excel, one address per row and one address line per column.

Consider the script..

[[Script]]
ClearHistory
Message1  "Activate Excel and press continue"
NameWindow "excel"
Message1 "Activate Word and press continue"
NameWindow "word"
Type Ctrl + End
Type Enter
Paste "The End"                       'Marker for end of copying
Type Ctrl + Home                     'This sets cursor to start of document
Loop
   Type Shift + End                  'This selects one line
   Type Ctrl + c                       'This copies the line
   Type Home
   Type Down                         'These move cursor to next line
   Wait 2
   If LastCopy = ""
      MakeClip "New"             'Marker for end of address
   EndIf
   If LastCopy = "The End"
      ExitLoop
   EndIf
EndLoop
Type Shift + End
Type BackSpace * 2
SetFocus "excel"
Type Ctrl + home
Loop
   If ThisPaste = ""
      SkipLoop                    'Skip blank lines
   EndIf
   If ThisPaste = "New"       'New Address so move to next row in excel
      Type Home
      Type Down
      SkipLoop
   EndIf
   PasteClipsFrom V1
   If NextPaste = "The End"
      ExitScript
   EndIf
   Type Right                    'move to next cell for next paste
EndLoop

It would run the same if it was

[[Script]]
ClearHistory
Message1 "Activate Excel and press continue"
NameWindow "excel"
Message1 "Activate Word and press continue"
NameWindow "word"
Type Ctrl + End
Type Enter
Paste "The End"
Type Ctrl + Home
Loop
Type Shift + End
Type Ctrl + c
Type Home
Type Down
Wait 2
If LastCopy = ""
MakeClip "New"
EndIf
If LastCopy = "The End"
ExitLoop
EndIf
EndLoop
Type Shift + End
Type BackSpace * 2
SetFocus "excel"
Type Ctrl + home
Loop
If ThisPaste = ""
SkipLoop
EndIf
If ThisPaste = "New"
Type Home
Type Down
SkipLoop
EndIf
PasteClipsFrom V1
If NextPaste = "The End"
ExitScript
EndIf
Type Right
EndLoop

But it would take mental gymnastics to figure out what it does if you ever wanted to alter it!

 

Back