language : Japanese | English

SAL (Sekaiju Application Language)

Home Examples Reference Download Buy FAQ Forum Author


Reference

Summary

1. The extension of textfile is "sal".

2. Text file's character code page is recognized as Windows control panel's character code page (Windows ANSI Code Page). For example, if you are using English Windows, it is 1252-Latin1, or you are using Japanese Windows, it is 932-Shift-JIS. For this, a sal file made in foreign Windows will not be able to recognized in your Windows. If you want to release sal file around the world, you can only use ASCII character such as alphabet and number. But if text file has BOM, UTF-8 and UTF-16LE's text file also get readable.

3. Text file's line feed code must be CR-LF.

4. Text file's max size is 65535 characters.

5. Text line's max size is 65535 characters.

6. After ;(semi coron) mark, the line is recognized as comment.

7. Each word must be separated by halfsize space, tab, or line feed code.

8. Each word's max size is 1023 characters.

9. Each word is case sensitive.

10. Integer is all treated as 32bit signed integer internally.

11. Available integer's type is only int (32bit signed).

12. Strings is all treated as UTF-16LE internally so you can use any character.

13. Strings's max size is 1023 characters. Even if you cat longer than 1023 bytes, it is ignored.

14. Defining function is not supported.

15. An include command is not supported.

Controlling structure
(do <op1> [<op2> ... <opN>]) Execute op1~opN.
(if <expression> <trueop> [<falseop>]) If expression is true(other than 0), execute trueop, else if expression is false(0), esecute falseop. falseop can be omitted. For omitting trueop, write NIL at the trueop. If you want to write multiple commands in trueop or falseop, please enclose them with (do section.
(switch <expression>
<case1val> <case1op>
[<case2val> <case2op>
...
<caseNval> <caseNop>])
If expression's value is case1val, execute case1op, expression's value is case2val, execute case2op, expression's value is caseNval, execute caseNop. Each caseKval must be integer. Unlike C language, break is not required with each caseKop. If you want to write multiple commands in caseKop, please enclose them with (do section.
(while <expression> <operation>) As long as expression's value is other than 0, execute operation. For avoiding to fall eternal loop, please write script so as to get expression's value getting 0 in someday. If you fall eternal loop, by pressing ESC key, you can terminate the script. If you want to write multiple commands in operation, please enclose them with (do section.
(forEachEvent <operation>) For each selected events, execute operation. It isn't allowed to nest forEachEvent. If you want to write multiple commands in operation, please enclose them with (do section.
(exit) Exit SAL script.
(error) Exit SAL script. When exit, the message box "Program called error." will be shown.
NIL A command that do nothing. Please use at (if command's true operation and so on.
SAL pre-defined variable
VERSION R return SAL's version. If 1.00, it returns 100.
TIMEBASE R return MIDIdata's timebase.
Now R return current playing position.
TRUE R return 1.
FALSE R return 0.
Literal Constant
-45 Integer must be written half-size 1234567890. If negative, add preceding -(minos).
"somestring" Strings must be inside with double quotation marks. If need to double quotation in the strings, escape it by \ sign.
Local variable definition
(int <varname> [<value>]) Create local variable of 32bit signed integer, and initialize it value. The varname's first character must be half-size alphabet and the left must be half-size alphabet or number.
(string <varname> [<value>]) Create local variable of UTF16-LE string, and initialize it value. The varname's first character must be half-size alphabet and the left must be half-size alphabet or number.
(bytearray <varname> [<value>]) Create local variable of byte array whose length is value bytes, and initialize each bytes zero. The varname's first character must be half-size alphabet and the left must be half-size alphabet or number.
Arithmetic operation / Comparision operation / Logical operation
(! <op1>) If op1 is other than 0, get 0, else if op1 is 0 get 1.
(abs <op1>) get absolute of op1.
(+ <op1> <op2>) get op1+op2.
(- <op1> <op2>) get op1-op2.
(* <op1> <op2>) get op1*op2.
(/ <op1> <op2>) get op1/op2.
(% <op1> <op2>) get op1%op2.
(&& <op1> <op2>) get op1&&op2.
(|| <op1> <op2>) get op1||op2.
(== <op1> <op2>) If op1 is equal to op2, get 1, otherwize, get 0.
(!= <op1> <op2>) If op1 isn't equal to op2, get 1, otherwize, get 0.
(<= <op1> <op2>) If op1<=op2 get 1, otherwize, get 0.
(>= <op1> <op2>) If op1>=op2 get 1, otherwize, get 0.
(< <op1> <op2>) If op1<op2 get 1, otherwize, get 0.
(> <op1> <op2>) If op1<op2 get 1, otherwize, get 0.
(min <op1> <op2>) Get smaller one of op1 and op2.
(max <op1> <op2>) Get bigger one of op1 and op2.
(random <op1> <op2>) Get random value between op1 and op2.
(clip <op1> <op2> <op3>) Get clipped op2 between op1 and op3.
Value set
(= <var> <value>) Set variable var to value. As long as this, strings also can be applied. Note that return value is undefined.
(+= <var> <value>) Set variable var to var+value. Note that return value is undefined.
(-= <var> <value>) Set variable var to var-value. Note that return value is undefined.
(*= <var> <value>) Set variable var to var*value. Note that return value is undefined.
(/= <var> <value>) Set variable var to var/value. Note that return value is undefined.
(%= <var> <value>) Set variable var to var%value. Note that return value is undefined.
(++ <var>) increment var. Note that return value is undefined.
(-- <var>) decrement var. Note that return value is undefined.
Strings and Byte array operation
(format <string1> [<string2>... <stringN>]) Get a chain of strings1 ... stringsN. If strings is integer, it is automatically replaced to decimal strings.
(getAt <op1> <index>) Get an element from string or bytearray op1 as integer.
(setAt <op1> <index> <value>) Set an element of string of bytearray op1 by integer.
(strlen <op1>) Get length of string op1.
(memlen <op1>) Get length of bytearray op1.
(strfind <op1> <pattern>) Get index where correspond to the pattern in string op1. If not found, returns -1.
(memfind <op1> <pattern>) Get index where correspond to the pettern in bytearray op1. If not found, returns -1.
(substr <op1> <start> <num>) 文字列op1のstart文字目からnum文字取り出した文字列を返します。
(submem <op1> <start> <num>) バイト配列op1のstartバイト目からnumバイト取り出したバイト配列を返します。
Time operation
(meas <time>) Get specified time's measure (1origin).
(beat <time>) Get specified time's beat (1origin).
(tick <time>) Get specifiedtime's tick (0origin).
(makeTime <measure> <beat> <tick>) Get specified measure(1origin):beat(1oringin):tick(0origin)'s time
Input / Output operation
(getInt <varname> <prompt> <min> <max>) Show a dialog to input integer. The dialog shows prompt string. The range of integer must be between min and max. The initial integer is equal to varname's value and the result is set to varname. If user pressed "Cancel" button, SAL shows "User pressed cancel." and SAL terminates immediately. This function doesn't return as long as user press "OK" button.
(getTime <varname> <prompt>) Show a dialog to input time as M:B:T format. The dialog shows prompt string. The initial value is equal to varname's time and the result is set varname as raw time. About time, please see "(meas", "(beat)", "(tick" and "(maketime". If user pressed "Cancel" button, SAL shows "User pressed cancel." and SAL terminates immediately. This function doesn't return as long as user press "OK" button.
(getString <varname> <prompt> <min> <max>) Show a dialog to input string. The dialog shows prompt string. The length of string must be between min and max characters. The initial string is equal to varname's value and the result is set to varname. If user pressed "Cancel" button, SAL shows "User pressed cancel." and SAL terminates immediately. This function doesn't return as long as user press "OK" button.
(pause <prompt1> [<prompt2> ... <promptN>]) Show a message box that shows prompt1...promptN text. Each prompt can be strings or integer. If user pressed "Cancel" button, SAL shows "User pressed cancel." and SAL terminates immediately. This function doesn't return unless user press "OK" button
(message <prompt1> [<prompt2> ... <promptN>]) Show prompt1...promptN text in the status bar. This function returns immediately.
Insert / Delete operation
(insert <time> <ch> <kind> <val1> <val2>...) Insert new event at specified time. Target track is selected by following way, if this is used within forEachEvent, new event's track is equal to each event's track, and if this is used out of forEachEvent, new event is inserted to active track, which is, track list window's active cell's track, or the other window's selected track. The kind must be SEQNUM, TEXT, COPYRIGHT, TRACKNAME, INSTNAME, LYRIC, MARKER, CUEPOINT, PROGNAME, DEVNAME, PORTPREFIX, CHANPREFIX, TEMPO, SMPTEOFFSET, TIMESIG, KEYSIG, SEQSPEC, NOTE, KEYAFT, CONTROL, PATCH, CHANAFT, WHEEL or SYSXDATA. The ch is MIDI channel(0~15)(if the event is not MIDI channel event, this value is ignored. The val1 and following is event's data. If NOTE, the values are Key, Vel, and Dur. If KEYAFT, the values are Key and Val. If PATCH, the values are program number and bank (CC#0-bank select MSB * 128 + CC#32-bank select LSB) (the second value can be omitted). If CHANAFT the value is Val. If WHEEL the value is Val(-8192~8191). If SYSXDATA, each value is byte array's value and the first must be 0xF0 and the last mut be 0xF7. If you insert an event to illegal track, for example, if you insert a note event to the first track (conductor track), this command does nothing.
(delete) Delete existing event. This command can be used only within forEachEvent. Note that end of track event can't be deleted. Once deleted, the event can't be refered again. So this command should be used at the last line in forEachEvent.
Event.Kind's Value
SEQNUM R Sequence number
TEXT R Text
COPYRIGHT R Copyright
TRACKNAME R Track name
INSTNAME R Instrument name
LYRIC R Lyric
MARKER R Marker
CUEPOINT R Cue point
PROGNAME R Program name
DEVNAME R Device name
CHANPREFIX R Channel prefix
PORTPREFIX R Port prefix
EOT R End of track
TEMPO R Tempo
SMPTEOFFSET R Smpte offset
TIMESIG R Time signature
KEYSIG R Key signature
SEQSPEC R Sequencer specific event
NOTE R Note
KEYAFT R Key aftertouch
CONTROL R Control change
PATCH R Program change
CHANAFT R Channel aftertouch
WHEEL R Pitch bend
SYSXDATA R System exclusive data
Variables available within forEachEvent
Event.Kind R Get event's kind. This value can be SEQNUM, TEXT, COPYRIGHT, TRACKNAME, INSTNAME, LYRIC, MARKER, CUEPOINT, PROGNAME, DEVNAME, CHANPREFIX, PORTPREFIX, EOT, TEMPO, SMPTEOFFSET, TIMESIG, KEYSIG, SEQSPEC, NOTE, KEYAFT, CONTROL, PATCH, CHANAFT, WHEEL, or SYSXDATA. This value is read-only.
Event.Time R/W Get / Set Event's time as raw time unit (in smpte base, subframe unit). Note that end of track event can't be set the other event.
Event.Chan R/W Get / Set Event's channel(0~15). This is available only for MIDI channel event (NOTE, KEYAFT, CONTROL, PATCH, CHANAFT, WHEEL). This can't be used for the other event. If used for the other event, it works undefined.
Event.Text R/W Get / Set Event's Text as string. This is available only for text event (TEXT, COPYRIGHT, TRACKNAME, INSTNAME, LYRIC, MARKER, CUEPOINT, PROGNAME, DEVNAME). This can't be used for the other event. If used for the other event, it works undefined.
Event.Track R/W Get / Set the track that the event is belonging(1~65536). It seems odd that track is treated as event's property, but it is convenience for getting or moving event's belonging track. Note that the format1 MIDIdata, tempo, time signature, key signature, and smpte offset event can be put only in the first track (conductor track), and MIDI channel event (NOTE, KEYAFT, CONTROL, PATCH, CHANAFT, WHEEL) can be put only in the second or following track. If you moved an event to illegal track or unexisting track, the moving is ignored. Also end of track event can't be moved.
Tempo.Val R/W Get / Set tempo's value. The unit is BPM * 100.
SmpteOffset.Mode R/W Get / Set SMPTE offset's mode (0~3).
SmpteOffset.Hour R/W Get / Set SMPTE offset's hour (0~23).
SmpteOffset.Min R/W Get / Set SMPTE offset's minute (0~59).
SmpteOffset.Sec R/W Get / Set SMPTE offset's second (0~59).
SmpteOffset.Frame R/W Get / Set SMPTE offset's frame (0~29).
SmpteOffset.SubFr R/W Get / Set SMPTE offset's subframe (0~99).
TimeSig.Num R/W Get / Set time signature's numerator. This affects only to the view, and doesn't affect to playing.
TimeSig.Den R/W Get / Set time signature's denominator. The value must be 1,2,4,8,16,or 32. This affects only to the view, and doesn't affect to playing.
TimeSig.Clo R/W Get / Set time signature's amount of clocks per quarter note. Usually, this value is 24. This affects only to the view, and doesn't affect to playing.
TimeSig.Blo R/W Get / Set time signature's amount of demisemiquarver (32nd note) per quarter note. Usually, this value is 8. This affects only to the view, and doesn't affect to playing.
KeySig.Sf R/W Get / Set key signature's amount of sharp or flat. If the value is positive, it means amount of sharp, or negative, it means amount of flat. For example, Emajor has four sharps, so the value is 4. This affects only to the view, and doesn't affect to playing.
KeySig.Mi R/W Get / Set Key signature is major (0) or minor (1). For example Cminor is minor, so the value is 1. This affects only to the view, and doesn't affect to playing.
SeqSpec.Data R/W Get / Set sequencer specific event's data as bytearray.
Note.Key R/W Get / Set note event's key(0~127).
Note.Vel R/W Get / Set note event's velocity(1~127).
Note.Dur R/W Get / Set note event's duration(1~65535).
KeyAft.Key R/W Get / Set key aftertouch event's key(0~127).
KeyAft.Val R/W Get / Set key aftertouch event's value(0~127).
Control.Num R/W Get / Set control change event's number (CC#)(0~127).
Control.Val R/W Get / Set control change event's value(0~127).
Patch.Val R/W Get / Set program change event's value(0~127).
Patch.Bank R/W Get / Set patch change event, which is combine of CC#0 and CC#32 and program change event, 's bank(0~16383). If this is used for program change event, it is ignored.
ChanAft.Val R/W Get / Set channel aftertouch event's value(0~127).
Wheel.Val R/W Get / Set pitch bend event's value(-8192~8191).
Sysx.Data R/W Get / Set system exclusive data's data as bytearray.


(C)2017-2018 kuzu all rights reserved. e-mail : ee65051#yahoo$co$jp (Modify # to @, and $ to . )