Getting Started


The goal of this section is to provide a brief introduction to SPL using real programs without getting bogged down in too many details and formal rules. Important similarities and differences between SPL and C/C++ will be pointed out where appropriate. Experienced programmers, especially C/C++ programmers, will have little trouble picking up SPL, beginners should follow the examples more carefully. For a good idea of the form and style of SPL programs, examine the SPL files located in your SPL sub-directory.


Our first SPL function will convert Fahrenheit temperatures to Celsius. We will create a text file that contains the function and invoke the function to convert a series of temperatures from Fahrenheit to centigrade.


SPL functions reside in text files with names that end with the extension .spl (e.g. myfun.spl). Functions are not case sensitive and have the following form:


function_name(optional argument list)

    local declarations;  


More than one function may reside in an SPL file. You may use any text editor to create an SPL function. DADiSP also provides an SPL editing environment, select


Tools -> SPL -> New SPL File


pull-down menu. This menu pops up a simple editor to create SPL functions.


Our Celsius function is based on the formula C = (5.0/9.0)(F-32.0). Select


Tools -> SPL -> New SPL File


or use your text editor to create a file named celsius.spl with the following code:


/* convert Fahrenheit to centigrade */

    local c;
    c = (5.0 / 9.0) * (f - 32.0);


We invoke our celsius function like any DADiSP built-in function. For example:


celsius(32)   returns: 0

celsius(212)  returns: 100

celsius(72)   returns: 22.22222222


DADiSP automatically loads the file celsius.spl and if there are no errors, runs the celsius function. In fact, DADiSP performs the following steps when we type celsius(32) :


  1. If celsius is a built-in function, run it.

  2. Else if celsius is an SPL function already in memory, run it.

  3. Else if celsius.spl exists, load it and run the function celsius.


Thus, an SPL function that resides in a file with the same name as the function (and extension .spl) is automatically loaded when invoked.


The celsius function can be explicitly loaded with the


Tools -> SPL -> Read SPL File


pull-down menu by choosing the file celsius.spl.






We can also load the file directly from the command line:




DADiSP should indicate the function was successfully loaded with the message:


 1 Function(s) Read From File 'celsius.spl'


Explicitly loading an SPL  function is useful during the development of the function.


Notice that our celsius function also operates on an entire series. For example, the { } can create a series and


 celsius({32, 212, 72})


returns a 3 point series with values {0, 100, 22.22222222}.