Csound Csound-dev Csound-tekno Search About

Setting an env var with spaces in it

Date2007-07-24 20:20
Fromrasputin
SubjectSetting an env var with spaces in it
On my Windows system (5.06d) say I want SSDIR to be at (e.g.)

C:/Documents and Settings/me/My Documents/Personal/Studio stuff/Csound files
2.0GB/CD 3 Csound Catalog/catalog_samples

but if I try to add that to the  clause or in .csoundrc this way

--env:SSDIR="{the string above}"

csound complains about the spaces in the string. I've tried it with single
quotes, # #, and haven't found a solution. 

If I run csound out of the command line, I can use the DOS SET command to
paste that path in

SET SSDIR={the string}

and csound finds the files it's looking for OK. Also, if I use csound5gui I
can put paths in the SFDIR/SSDIR/etc boxes in the Configure window
Environment tab, but of course this doesn't propagate back to the main
install. 

Any ideas for me?

Thanks kindly!

...r...
-- 
View this message in context: http://www.nabble.com/Setting-an-env-var-with-spaces-in-it-tf4138111.html#a11770064
Sent from the Csound - General mailing list archive at Nabble.com.

Date2007-07-27 18:01
From"Steven Yi"
SubjectRe: Setting an env var with spaces in it
AttachmentsNone  

Date2007-07-27 18:16
Fromrasputin
SubjectRe: Setting an env var with spaces in it
Thanks for the suggestion, Steven. Escaping the spaces didn't seem to work.
But I used CSound Editor to change every space to '%20' and lo and behold!
that did work....so even though it make not look the most elegant the point
is that now I can set SSDIRs and SFDIRs in my csds. 

My experiment was to use Spjut's FM_Example program, which requires a file
Hamlet.aif which on my system is in "C:\Documents and Settings\music\My
Documents\Personal\Studio stuff\Csound files 2.0GB\CD 3 Csound
Catalog\catalog_samples"



--env:SFDIR="C:/Documents%20and%20Settings/tims/My%20Documents/Personal/Studio%20stuff/Csound%20files%202.0GB/CD%203%20Csound%20Catalog/catalog_samples"



          instr     11 ;FM SCI-FI VOICE EXAMPLE
a1        soundin   "Hamlet.aif"
a3        line      0,p3,0.4            ; MODULATION INDEX
a2        oscil     10000,256-a3*a1,1   ; MODULATE
          out       a2
          endin                    




f1 0 4096 10 1 ;SINE TABLE
;-------------------------
i11 0 22





Hi Rasputin,

Have you tried using \ before every space, so something like:

--env:SSDIR="c:/Documents\ and\ Settings/me/My\ Documents..."

Not sure that will work but could do it.

steven

-- 
View this message in context: http://www.nabble.com/Setting-an-env-var-with-spaces-in-it-tf4138111.html#a11833278
Sent from the Csound - General mailing list archive at Nabble.com.

Date2007-08-01 20:33
Fromrasputin
SubjectRe: Setting an env var with spaces in it
Well, something is awry here. I thought I had this working, but haven't been
able to since....I have been trying to set SFDIR/SSDIR in .csd files or
.csoundrc and I can't get them to work when using long paths like that
below. That is, if I put in  something like

--env:SSDIR=../catalog_samples

that works, but not if I use something like 

--env:SSDIR="C:/Documents%20and%20Settings/tims/My%20Documents/Personal/Studio%20stuff/Csound%20files%202.0GB/CD%203%20Csound%20Catalog/catalog_samples"

It doesn't give an error; just fails to find the needed files (either trying
to read by soundin, GEN01)

I think this is an error and am going to enter it into sourceforge.


Thanks for the suggestion, Steven. Escaping the spaces didn't seem to work.
But I used CSound Editor to change every space to '%20' and lo and behold!
that did work....so even though it make not look the most elegant the point
is that now I can set SSDIRs and SFDIRs in my csds. 

My experiment was to use Spjut's FM_Example program, which requires a file
Hamlet.aif which on my system is in "C:\Documents and Settings\music\My
Documents\Personal\Studio stuff\Csound files 2.0GB\CD 3 Csound
Catalog\catalog_samples"



--env:SFDIR="C:/Documents%20and%20Settings/tims/My%20Documents/Personal/Studio%20stuff/Csound%20files%202.0GB/CD%203%20Csound%20Catalog/catalog_samples"



          instr     11 ;FM SCI-FI VOICE EXAMPLE
a1        soundin   "Hamlet.aif"
a3        line      0,p3,0.4            ; MODULATION INDEX
a2        oscil     10000,256-a3*a1,1   ; MODULATE
          out       a2
          endin                    




f1 0 4096 10 1 ;SINE TABLE
;-------------------------
i11 0 22





Steven Yi wrote:
> 
> Hi Rasputin,
> 
> Have you tried using \ before every space, so something like:
> 
> --env:SSDIR="c:/Documents\ and\ Settings/me/My\ Documents..."
> 
> Not sure that will work but could do it.
> 
> steven
> 
> 

-- 
View this message in context: http://www.nabble.com/Setting-an-env-var-with-spaces-in-it-tf4138111.html#a11952328
Sent from the Csound - General mailing list archive at Nabble.com.

Date2007-08-01 22:36
From"Steven Yi"
SubjectRe: Setting an env var with spaces in it
AttachmentsNone  

Date2007-08-01 23:08
Fromrasputin
SubjectRe: Setting an env var with spaces in it
Thanks, Steven; I forgot that | more works on WinXP too..

Yes, it does appear to absorb the entire string. 

Trimming out the non-relevant parts: csound first appears to set the various
ENV variables to the current directory:

...
decode_long expression-opt
UnifiedCSD:  toot08.csd
Environment variable 'SADIR' has been set to 'C:\Documents and
Settings\zorg\My
Documents\Personal\Studio stuff\Csound files 2.0GB\My CSound Projects'
Environment variable 'SSDIR' has been set to 'C:\Documents and
Settings\zorg\My
Documents\Personal\Studio stuff\Csound files 2.0GB\My CSound Projects'
Environment variable 'INCDIR' has been set to 'C:\Documents and
Settings\zorg\My
 Documents\Personal\Studio stuff\Csound files 2.0GB\My CSound Projects'
Environment variable 'MFDIR' has been set to 'C:\Documents and
Settings\zorg\My
Documents\Personal\Studio stuff\Csound files 2.0GB\My CSound Projects'
STARTING FILE
...

then it encounters the  clause:

...
Creating options
decode_long
env:SSDIR=C:\Documents%20and%20Settings\zorg\My%20Documents\Personal
\Studio%20stuff\Csound%20files%202.0GB\CD%201%20CSound%20Book%20HTML\tutorials\t
oots
Environment variable 'SSDIR' has been set to
'C:\Documents%20and%20Settings\zorg
\My%20Documents\Personal\Studio%20stuff\Csound%20files%202.0GB\CD%201%20CSound%2
0Book%20HTML\tutorials\toots'
Creating orchestra
...

whereas if I leave spaces in the env argument it just stops parsing at the
first one:

...
decode_long env:SSDIR="C:\Documents
Environment variable 'SSDIR' has been set to '"C:\Documents'
argc=6 Additional string "Documents\Personal\Studio"
...

So since SSDIR got set wrong, of course it won't find my files.
I submitted this as a bug on the soundforge csound page.  But if there's any
kind of workaround I will be delighted to hear about it!

Thanks again, Steven.

...r...


Could you use -v when running csound and see if what you set is what
csound got?  I wonder if there is a problem with the length of the
string.  With -v, you'll probably want to run it like:

csound -v myfile.csd | more

it should tell you what the SSDIR is set to.

steven

-- 
View this message in context: http://www.nabble.com/Setting-an-env-var-with-spaces-in-it-tf4138111.html#a11954895
Sent from the Csound - General mailing list archive at Nabble.com.