Programmer Guide/Macro Library/BSF: Difference between revisions
From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import) |
No edit summary |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}}__NOTOC__ | |||
*File: BSF.STX, linked to library STX.LIB | |||
*Title: soundfile handling | |||
:{|class="keinrahmen" | |||
|[[#NewDialog|NewDialog]] ||— | |||
|[[#OpenDialog|OpenDialog]] | |||
|- | |||
|[[#Open|Open]] ||— | |||
|[[#Close|Close]] ||— | |||
|[[#CloseAll|CloaseAll] ||— | |||
|[[#Select|Select]] ||— | |||
|[[#Truncate|Truncate]] | |||
|} | |||
This library uses the following global variables and items | |||
== | {|class="einrahmen" | ||
!name !!type !!description | |||
|@ParSoundFileNew ||global variable ||default values for function NewDialog | |||
|@ListAudioSampleCode ||global variable ||list of defined sample code keywords | |||
|@MaxAudioChannels ||global variable ||maximum number of soundfile channels | |||
|@MaxAudioSRate ||global variable ||maximum sampling rate in Hz | |||
|@ListAudioSRate ||global variable ||list of standard sampling rate values | |||
|@TempDir ||global variable ||directory for temporary files | |||
<code> | |BSFOpenList ||table item ||list of soundfiles opened with <code>BSF OPEN</code><BR>only used for BScript applications | ||
|SoundFileList ||shell variable ||name of the shared soundfile table item<BR>see [[../BSTXIni|BSTXIni]] | |||
|} | |||
==NewDialog== | |||
;<var>path</var> | ;<code>BSF NEWDIALOG [ <var>srate</var> [ ; <var>nch</var> ; <var>code</var> ]</code>: New soundfile dialog. | ||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
|<var>type</var> | |||
|Selects the action to perform:<BR> | |||
<code>LOAD</code> or <code>OPEN</code> → open existing file<BR> | |||
<code>SAVE</code> or <code>NEW</code> → create new file | |||
|<code>OPEN</code> | |||
|- | |||
|<var>title</var> | |||
|The caption of the dialog window. | |||
|<code>Select File</code> | |||
|- | |||
|<var>file</var> | |||
|The default file or directory. | |||
|current directory | |||
|- | |||
<code>0</code> | |<var>ftype1</var> ... | ||
|Each <var>ftype</var> argument defines one entry of the filetype-combobox of the dialog.<BR> | |||
Each filetype is defined by the string <code><var>extension</var>=<var>description</var></code>.<BR> | |||
== | Example: <code>WAV=wave files</code><BR> | ||
If a <var>ftype</var> argument is the name of a (simple) table item, each entry of the table defines a filetype. | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<var>path</var> ||The full pathname of the file to be opened or created. | |||
|- | |||
|''empty string'' ||If the dialog was canceled. | |||
|} | |||
;See also: | |||
==FileCommands== | |||
;<code>BUTIL COPYFILE <var>src</var> ; <var>dst</var></code>: Copy file. | |||
;<code>BUTIL MOVEFILE <var>src</var> ; <var>dst</var></code>: Copy file. | |||
;<code>BUTIL DELETEFILE <var>src</var></code>: Copy file. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
<code> | |<var>src</var> | ||
|The file to copy, move (rename) or delete. | |||
| | |||
|- | |||
|<var>dst</var> | |||
|The target file or directory for copy or move (rename) | |||
| | |||
|- | |||
!RESULT !!description | |||
|- | |||
: | |<code>0</code> ||success | ||
|- | |||
;<var>code</var> | |<var>rc</var> ||The non-zero error code if the command has failed. | ||
|} | |||
: | ;See also: | ||
==DirectoryDialog== | |||
==== | ;<code>BUTIL DIRECTORYDIALOG [ <var>title</var> ; <var>path</var> ; <var>restore</var> ; <var>sdmode</var> ; <var>sdvalue</var> ]</code>: | ||
;<code>DIRECTORYDIALOG [ '<var>title</var>' [ '<var>path</var>' '<var>restore</var>' '<var>sdmode</var>' '<var>sdvalue</var>' ]</code>: Dialog to select a directory. | |||
The | {|class="einrahmen" | ||
!argument !!description !!default | |||
|- | |||
== | |<var>title</var> | ||
|The caption of the dialog window. | |||
|<code>Select Directory</code> | |||
|- | |||
{| | |<var>path</var> | ||
|The default directory. | |||
|current directory | |||
|- | |||
|<var>restore</var> | |||
|<code>no</code> or <code>0</code> → do not restore current directory<BR> | |||
<code>yes</code> or <code>1</code> → restore current directory | |||
|<code>no</code> | |||
|- | |||
|<var>sdmode</var> | |||
|<code>no</code> or <code>0</code> → do not display the '''subdirectories''' checkbox<BR> | |||
<code>yes</code> or <code>1</code> → display the '''subdirectories''' checkbox | |||
|<code>no</code> | |||
|- | |||
|<var>sdvalue</var> | |||
|Initial state of the '''subdirectories''' checkbox: <code>off</code> (=<code>0</code>) or <code>on</code> (=<code>1</code>) | |||
|<code>off</code> | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<var>path</var> ||If <var>sdmode</var> equals <code>no</code> → The full pathname of the selected directory. | |||
|- | |||
|<var>path;sdvalue</var> ||If <var>sdmode</var> equals <code>yes</code> → The full pathname of the selected directory and the value of the '''subdirectories''' checkbox (<code>0</code> or <code>1</code>). | |||
|- | |||
|''empty string'' ||If the dialog was canceled. | |||
|} | |||
;See also: | |||
==GetDirectory== | |||
;<code>BUTIL GETDIRECTORY <var>path</var></code>: Check if the directory exists. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
|<var>path</var> | |||
|The directory to be checked. | |||
| | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<var>path</var> ||The fullpath of the specified directory. | |||
|- | |||
|<code>$@root</code> ||The {{STX}} installation directory if the specified directory was not found. | |||
|} | |||
;See also: | |||
==Directory== | |||
;<code>BUTIL DIRECTORY [ <var>path</var></code> ]: Select directory and/or get full pathname of working directory. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
|<var>path</var> | |||
|The directory to be selected. | |||
| | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<var>path</var> ||The fullpath of the selected/current {{STX}} working directory. | |||
|} | |||
;See also: | |||
==GetSwitch== | |||
;<code>BUTIL GETSWITCH <var>val</var> ; <var>defval</var></code>: Verify and return boolean value. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
|<var>val</var> | |||
|The value to check.<BR>Valid values are: <code>0=no=false=off, 1=yes=true=on</code> | |||
| | |||
|- | |||
|<var>defval</var> | |||
|The default value to be used if <var>val</var> is invalid. The same values as for <var>val</var> can be specified. | |||
|0 | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<code>0</code> or <code>1</code> | |||
| | |||
|} | |||
;See also: | |||
==GetKeyWord== | |||
;<code>BUTIL GETKEYWORD <var>val</var> ; <var>defval</var> ; <var>keyword1</var> ...</code>: Verify keyword and return keyword value. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
|<var>val</var> | |||
|The value to check. | |||
| | |||
|- | |||
|<var>defval</var> | |||
|The default value to be returned if <var>val</var> is not a keyword. | |||
| | |||
|- | |||
|<var>keyword1</var> ... | |||
|Blank seperated list of keywords. | |||
| | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<var>keyword</var> ||If <var>val</var> is a keyword or an abbreviation of a keyword. | |||
|- | |||
|<var>defval</var> ||otherwise | |||
|} | |||
;See also: | |||
==GetKeyIndex== | |||
;<code>BUTIL GETKEYINDEX <var>val</var> ; <var>defval</var> ; <var>keyword1</var> ...</code>: Verify keyword (or index) and return keyword index. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
|<var>val</var> | |||
|The value to check. | |||
| | |||
|- | |||
|<var>defval</var> | |||
|The default value to be returned if <var>val</var> is not a keyword. | |||
| | |||
|- | |||
|<var>keyword1</var> ... | |||
|Blank seperated list of keywords. | |||
| | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<var>keyindex</var> ||The zero based index of the matching keyword, if <var>val</var> is a keyword or an abbreviation of a keyword. | |||
|- | |||
|<var>defval</var> ||otherwise | |||
|} | |||
;See also: | |||
==SelectTable== | |||
;<code>BUTIL SELECTTABLE <var>table</var> <var>sel</var></code>: Select table entries. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |- | ||
|< | |<var>table</var> | ||
| | |Name of a table item. | ||
| | |||
|- | |- | ||
|<code> | |<var>sel</var> | ||
| | |The select command:<BR> | ||
<code>ALL</code> → select all entries<BR> | |||
<code>TOGGLE</code> → toggle (invert) selection<BR> | |||
<code>NONE</code> → clear selection, deseclect all entries | |||
| | |||
|- | |- | ||
!RESULT !!description | |||
|- | |- | ||
| | |<var>nsel</var> ||Number of selected table entries. | ||
|} | |} | ||
;See also: | |||
Revision as of 16:17, 11 May 2011
- File: BSF.STX, linked to library STX.LIB
- Title: soundfile handling
This library uses the following global variables and items
name | type | description | @ParSoundFileNew | global variable | default values for function NewDialog | @ListAudioSampleCode | global variable | list of defined sample code keywords | @MaxAudioChannels | global variable | maximum number of soundfile channels | @MaxAudioSRate | global variable | maximum sampling rate in Hz | @ListAudioSRate | global variable | list of standard sampling rate values | @TempDir | global variable | directory for temporary files | BSFOpenList | table item | list of soundfiles opened with BSF OPEN only used for BScript applications |
SoundFileList | shell variable | name of the shared soundfile table item see BSTXIni |
---|
NewDialog
BSF NEWDIALOG [ srate [ ; nch ; code ]
- New soundfile dialog.
argument | description | default |
---|---|---|
type | Selects the action to perform:
|
OPEN
|
title | The caption of the dialog window. | Select File
|
file | The default file or directory. | current directory |
ftype1 ... | Each ftype argument defines one entry of the filetype-combobox of the dialog. Each filetype is defined by the string | |
RESULT | description | |
path | The full pathname of the file to be opened or created. | |
empty string | If the dialog was canceled. |
- See also
FileCommands
BUTIL COPYFILE src ; dst
- Copy file.
BUTIL MOVEFILE src ; dst
- Copy file.
BUTIL DELETEFILE src
- Copy file.
argument | description | default |
---|---|---|
src | The file to copy, move (rename) or delete. | |
dst | The target file or directory for copy or move (rename) | |
RESULT | description | |
0 |
success | |
rc | The non-zero error code if the command has failed. |
- See also
DirectoryDialog
BUTIL DIRECTORYDIALOG [ title ; path ; restore ; sdmode ; sdvalue ]
DIRECTORYDIALOG [ 'title' [ 'path' 'restore' 'sdmode' 'sdvalue' ]
- Dialog to select a directory.
argument | description | default |
---|---|---|
title | The caption of the dialog window. | Select Directory
|
path | The default directory. | current directory |
restore | no or 0 → do not restore current directory
|
no
|
sdmode | no or 0 → do not display the subdirectories checkbox
|
no
|
sdvalue | Initial state of the subdirectories checkbox: off (=0 ) or on (=1 )
|
off
|
RESULT | description | |
path | If sdmode equals no → The full pathname of the selected directory.
| |
path;sdvalue | If sdmode equals yes → The full pathname of the selected directory and the value of the subdirectories checkbox (0 or 1 ).
| |
empty string | If the dialog was canceled. |
- See also
GetDirectory
BUTIL GETDIRECTORY path
- Check if the directory exists.
argument | description | default |
---|---|---|
path | The directory to be checked. | |
RESULT | description | |
path | The fullpath of the specified directory. | |
$@root |
The STx installation directory if the specified directory was not found. |
- See also
Directory
BUTIL DIRECTORY [ path
]- Select directory and/or get full pathname of working directory.
argument | description | default |
---|---|---|
path | The directory to be selected. | |
RESULT | description | |
path | The fullpath of the selected/current STx working directory. |
- See also
GetSwitch
BUTIL GETSWITCH val ; defval
- Verify and return boolean value.
argument | description | default |
---|---|---|
val | The value to check. Valid values are: 0=no=false=off, 1=yes=true=on
|
|
defval | The default value to be used if val is invalid. The same values as for val can be specified. | 0 |
RESULT | description | |
0 or 1
|
- See also
GetKeyWord
BUTIL GETKEYWORD val ; defval ; keyword1 ...
- Verify keyword and return keyword value.
argument | description | default |
---|---|---|
val | The value to check. | |
defval | The default value to be returned if val is not a keyword. | |
keyword1 ... | Blank seperated list of keywords. | |
RESULT | description | |
keyword | If val is a keyword or an abbreviation of a keyword. | |
defval | otherwise |
- See also
GetKeyIndex
BUTIL GETKEYINDEX val ; defval ; keyword1 ...
- Verify keyword (or index) and return keyword index.
argument | description | default |
---|---|---|
val | The value to check. | |
defval | The default value to be returned if val is not a keyword. | |
keyword1 ... | Blank seperated list of keywords. | |
RESULT | description | |
keyindex | The zero based index of the matching keyword, if val is a keyword or an abbreviation of a keyword. | |
defval | otherwise |
- See also
SelectTable
BUTIL SELECTTABLE table sel
- Select table entries.
argument | description | default |
---|---|---|
table | Name of a table item. | |
sel | The select command:
|
|
RESULT | description | |
nsel | Number of selected table entries. |
- See also