User-Defined Opcode Database

FilNam

returns the name of a file path

Download UDO File

Description

returns the name part of a file path string

Syntax

Snam FilNam Spath

Initialization

Spath - full path name as string
Snam - name part

Code

  opcode FilNam, S, S
Spath      xin
ipos      strrindex Spath, "/"
Snam      strsub    Spath, ipos+1
          xout      Snam
  endop

Examples

<CsoundSynthesizer>
<CsOptions>
-m0
</CsOptions>
<CsInstruments>

  opcode FilNam, S, S
;returns the name of a file path
Spath      xin
ipos      strrindex Spath, "/"
Snam      strsub    Spath, ipos+1
          xout      Snam
  endop
  
  instr name
          prints    "Printing name:\n"
Snam      FilNam    "/my/dir/my/file.WAV"
          puts      Snam, 1  
  endin
  
</CsInstruments>
<CsScore>
i "name" 0 0
</CsScore>
</CsoundSynthesizer>

Credits

joachim heintz 2012


Previous Home Next
FilDir   FilSuf