• UK
  • US
  • Français
  • Deutsch
  • Español (precios €)
  • Portugal
  • Polski
  • 日本人
  • 中國傳統
  • 简化中国

Spike2 scripts


Useful functions

Copy data to and from grid views
ghgridutils.s2s (10/17)

gridutils.zip

This library contains functions for converting arrays of strings to number format and vice versa. They are needed when working with grid views because numbers must be converted to strings before adding them to a grid and columns and rows of strings in a grid must be converted back into numbers before they can be processed further with a script. You can find a script that demonstrates how these functions are used here.

Copy this library to the include folder of your Spiken folder in My Documents. To use these functions add the line #include “ghgridutils.s2s” at the top of your script.

This script requires Spike2 v8.06 or higher. From versions 8.14 and 9.02 onwards, this script will be added to the include folder of the Spike2 application.

Sequencer Library
seqlib.s2s (02/10)

SeqLib.zip

SeqLib - a library of functions to help with calculations of sequencer variable values. SeqLib contains a much requested function; something that calculates the variable value required to set a DAC output to a specified voltage. This is the equivalent of the VDAC32() operator built into the sequence compiler but can be used in a much more flexible manner. Other SeqLib functions convert time to sequencer ticks and generate variable values suitable for writing to the digital outputs or controlling the cosine outputs.

Randomise Order of an Integer Array
shuffle eg.s2s (08/15)

shuffle.zip

This function randomises the order of items in an integer array. A typical application might be to randomise the order of presentation of common and rare auditory stimuli.

News Flash
Newsflash example.s2s (02/05)

nwsflash.zip

If you add these functions to your own scripts you can display Message boxes similar to those generated by the built-in Message() procedure but with the following extra features:

  • You can define the screen position where the Message box appears.
  • There is an optional system sound (beep) when the message is first displayed.
  • The message closes automatically after a specified time has elapsed, thus avoiding the need to press a key before you can continue.

Hide/Restore Floating Windows
HideRestoreApps.s2s (03/05)

hiderest.zip

These procedures can be used to hide all the floating windows and toolbars etc. at the start of a script and restore them at the end. This maximises the available screen area during script operation. The gFloat%[] array should be a global at the start of your script.

These procedures are used in many CED scripts. The particular variant given here keeps the script window itself hidden. You can find a slightly simplified version of these procedures and further information under App() in the Spike2 Help index.

Clear Logs
ClearLogQ.s2s (03/05)

clearlog.zip

This Spike2 script procedure checks whether there is any text in the Log window. If the log contains text a Query box is displayed so that you can choose whether or not to clear the log before continuing. If you choose the answer No, the text caret is moved to the end of the log file. The procedure leaves the current view unchanged.

Add this function to the functions and procedures section of your own scripts. You can then call it at the beginning of script functions that write data to the log file or perhaps in the Quit() function, as an aid to keeping the log file in a tidy state.

DoButtons
DoButtons example.s2s (06/06)

dobuttons.zip

This function allows you to set the enabled /disabled state of multiple toolbar buttons.

The ToolbarEnable() and ToolbarClear() script functions can only act on one (or all) buttons. Thus, you may need sequences of 4 or 5 calls to ToolbarEnable() at each point in the script where you need to set the enabled state of multiple buttons. The DoButtons%() function provides a method of setting the state of multiple buttons with a single function call. To use it, simply copy the DoButtons%() function into the functions and procedures section of your script and call it as illustrated in the example script.

Add this function to the functions and procedures section of your own scripts. You can then call it at the beginning of script functions that write data to the log file or perhaps in the Quit() function, as an aid to keeping the log file in a tidy state.

This function requires Spike2 v5.14 or higher.

Some of these scripts have come from users rather than the CED team. If you have a script that you would like to offer to fellow users via this page, please tell Simon Gray. We provide some scripts for Signal too.

These scripts are stored as WinZip files, myscript.zip, except where they are shown as spike\scripts\myscript.s2s. Those latter files were installed with Spike2 and spike stands for the directory in which you installed Spike2. See the summaries by clicking on the description in the side menu. Then you can down-load them by clicking on the filename.

Cambridge Electronic Design Limited

Registered in England: 00972132

Registered office:

  • Cambridge Electronic Design Limited,
  • Technical Centre,
  • 139 Cambridge Road,
  • Milton,
  • Cambridge CB24 6AZ
  • ENGLAND.

VAT: GB 214 2617 96

Producer registration number: WEE/BD0050TZ

Terms and Conditions of Sale

For our US customers, we can provide tax form W-8BEN, that identifies us as a UK company.

DUNS: 219151016
CAGE/NCAGE: KB797
NAICS: 423490
Commodity codes
Hardware: 84716070
Software: 85235190
×

By email:

info@ced.co.uk

By post:
  • Cambridge Electronic Design Limited,
  • Technical Centre,
  • 139 Cambridge Road,
  • Milton,
  • Cambridge CB24 6AZ
  • ENGLAND.
By telephone:

(Int.+44) (0)1223 420186

From North America (Toll Free):

1 800 345 7794

×