Cabbage Logo
Back to Cabbage Site

Cabbage 2 beta : pwd and readfi opcodes not working

While trying to get over the soundfiler /table not loading files, I stumbled on the following.
The following instrument (taken from Csound manual) does not work with Cabb2 beta but works with Cabbage 1.

instr 10
Swd pwd
printf_i “Working directory is ‘%s’\n”, 1, Swd
prints “Reading myself =):\n”
Sline, iLineNum readfi “combo.txt”
printf_i “Line %d: %s”, iLineNum, iLineNum, Sline
if iLineNum != -1 igoto read

Here is the error generated. :

error: syntax error, unexpected T_IDENT (token “pwd”) from file C:\Users\Cube\Documents\Csound\soundfiler.csd (1)
line 26:
. >>> Swd pwd <<<
Unexpected untyped word Swd when expecting a variable
Parsing failed due to invalid input!
Stopping on parser failure
cannot compile orchestra

Hope this helps

Strange that it works with Cabbage 1 but not with Cabbage 2 considering they are both using the same version of Csound? I’ll investigate.

It’s working Ok for me, can you check and see if there is a system.dll in your Cabbage directory? I think this opcode is contained within that.

I don’t have that dll. It was not included within the last beta zip file. In cabbage 1, there is only one dll called system_call.dll but I suppose this is not the right one.

Hmm, I’ll take a look. Something is off but sound be say to fix if it works for me. Might be time to start distributing a full cabbage 2 installer…

Agree. Maybe not installer but at least a portable version as a zip file. This avoids writing into windows registry and maintenance easy : delete folder and replace it.
Didn’t you change compiler from mingwin to visual studio between cabb 1 and 2 ? Maybe this is why I do not find the Dll and that the ones I have don’t work?

I still build against the mingw binaries for now. That shouldn’t be the problem. A zip is a good idea. I’ll try to get one prepared by this evening.

Can you try these dlls? Simply replace the ones in your Cabbage dir with the ones here. Actually, might be best to backup the ones you’re replacing first, just in case!

Opcodes pwd et readfi work fine now… thank you !!
I ll check some other examples tomorrow and let you know if something goes wrong.

I use cabbage 2 in a separate directory (as standalone) from cabbage 1 so I won’t break cabb1.

[EDIT] : I was a bit too much enthusiastic Reading file is ok. Pwd complains:

INIT ERROR in instr 10: cannot determine current directory
Swd pwd
Working directory is ‘’
Reading myself =):

Ok, but pwd is recognised by Csound and is attempting to run, but is having problems. I wonder what the problem is? What is the directory you are working from? Could it be a permission thing that is causing issues? Also, have you tried using the reserved channel CSD_PATH?

sDirectory chnget "CSD_PATH"

This should give you the directory that the current .csd file is in. From there you can use relatve paths to other folders?

Hi Rory,

I am trying to build my VST on Windows (on my gf computer so I try not to make a mess in her computer haha)

It’s working well on my mac but on windows the readfi opcode returns this error: "Unexpected untyped word lLinNum when expecting a variable" and "syntax error, unexpected T_IDENT (token "readfi").

Should I also replace the .dlls? Or is it another issue? I’m using the latest Pro version you sent me.



What is lLinNum, and should it not be a iLinNum? Or kLinNum? I think readfi is part of the native opcodes, so it shouldn’t need access to any plugin opcodes?

Sorry it’s a typo error I made when typing the error (I’m on a different computer). I used iLinNum this way:

Sline, iLinNum readfi SFileName

According to the docs it’s a plugin opcode in cs_date:

But why does it work on my mac then?

Yeah, I just went over the source now and spotted that. So you will need to include the cs_date.dll, and then load it. The best way to handle this on Windows is to put the dll into the Program Data folder you use for your assets, and then use the --opcode-lib= flag in your CsOptions section.

Thanks! Does it change something on how to distribute Csound with the VST? Since Csound is embedded in the exported file (Pro version) without the plugin I don’t know if I have additional work to do to include plugin opcodes. Sorry for this naive question, I’m not experimented with this subject!

The simplest is to add them explicitly using that --opcode-lib flag. That will prevent any conflicts with any system wide Csound. :+1:

1 Like

So I’m now using:

-n -d -+rtmidi=NULL -M0 -m0d --displays --opcode-lib=cs_date.dll

cs_date.dll is at the root on my project folder. Unfortunately I still have the error, it might be a path error? I don’t know if relative links are supported.

I think you’ll need an absolute path. Otherwise you will need to include the dll beside the plugin dll, which is messy because hosts will try to open it as a plugin. Almost everyone on Windows has their program data on the C: drive, but this is not a 100% guarantee. Still, I think it’s safest way to go.

ah yeah I didnt think about this issue…

on MacOS I was 100% confident the very light antipiracy script was working well, but on windows if users install their vst on D: drive for example and have a weird folder structure it might break everything. And since I rely on writing/reading a file on the disk, I would need to use readfi. Maybe I can try to find a workaround…

Oh yes, that’s a valid point. yeah, windows is a bit of a pain :roll_eyes: