create and write a text file

I want create and write into a text file  using a script DXL but DOORS is running and accessed via Citrix .

I appreciate if can give some specific code. 
Thanks .

Locale loc = userLocale 
const string fName="C:\\Users\\FOCUS\\Desktop\\Sana\\testdxl.txt"
Stream writtingBuf = write(fName)
Module m = current
writtingBuf <<  name(m) "\n" 
string val
Object o
for o in m do {
  Column c
  for c in m do{
              
        val= text(c,o)

    if((title c=="Service") && (val=="19"))
    {

        for c in m do{ 
        val= text(c,o)
        writtingBuf << title c " of object " (o."Absolute Number" "") " : " val "\n"
        }
    }

}
   
} 

 close(writtingBuf)

And I get this error knowing that I created the file in the correct location : 

-R-E- DXL: <Line:4> cannot open file (C:\Users\FOCUS\Desktop\Sana\testdxl.txt) for writing (No such file or directory)
-I- DXL: execution halted

 


Sana.Mejri - Wed Aug 02 09:06:12 EDT 2017

Re: create and write a text file
PekkaMakinen - Thu Aug 03 01:21:37 EDT 2017

No problems in using your (slightly modified) code to write to disk. Please check your access rights on the Citrix servers, do you have interactive access to the location? On some Citrix installations also the local (meaning your desktop from where you access Citrix) drives are mapped, check if you can use these.

One note on your code: you have two "for c in m do" loops - as the inner one uses the same variable name as the outer, it will break  the outer loop.

Re: create and write a text file
HPM2BP - Thu Aug 03 04:56:01 EDT 2017

Hello!

 

First of all I'd check if the directory even exists, somehow like this:

if (!(fileExists_ (dir)){             //If the directory doesn't exist yet, we create it
        mkdir (dir)
}

Also it's possible that you don't have the rights to write to those folders, in that case I'd use C:\Temp