ftexists

ftexists — Query if a given table exists

Description

Plugin opcode in emugens.

Returns 1 if a given index refers to an existing table, 0 if the table does not exist. Works at i-time if output is an ivariable, at k-time otherwise

Syntax

iexists ftexists ifn 
kexists ftexists kfn / ifn

Arguments

ifn / kfm - The table to query

Output

iexists / kexists - 1 if the table exists, 0 otherwise

Examples

Here is an example of the ftexists opcode. It uses the file ftexists.csd.

Example 391. Example of the ftexists opcode.

<CsoundSynthesizer>
<CsOptions>

--nosound 

</CsOptions>

<CsInstruments>

; This is the example file for ftexists

/*

  ftexists

  Returns 1 if a given table index refers to an existing
  ftable

  iexists  ftexists  ifn
  kexists  ftexists  kfn

  Args:
  	ifn / kfn: the table index to query

  Returns:
    iexists / kexists: 1 if a table with index ifn exists, 0 otherwise

*/

gifn1 ftgen 0, 0, 8, 2, 0

instr 1
    iexists1 ftexists gifn1
    print iexists1

    iexists2 ftexists 2
    print iexists2

    kexists ftexists 3
    printf "table 3 exists at time %f", kexists, timeinsts()
endin

</CsInstruments>

<CsScore>

f 2 0 8 2 0
f 3 1.5 8 2 0

i 1 0 2

</CsScore>
</CsoundSynthesizer>


See also

Table Control:Table Queries

Credits

By: Eduardo Moguillansky 2019

New plugin in version 6.14