creating file to output to in Progress 8

tjsingh

Member
Hi

I am trying to output to a file using PUT statement but it does not seem to work. Basic code below:

--------------------------------------------------------------------------------
def var filename as char no-undo.

DEFINE STREAM stOrd.

filename = "invSara" + TRIM(STRING(day(TODAY))) +
TRIM(STRING(month(TODAY))) + TRIM(STRING(year(TODAY))) + ".txt".

output stream stOrd to filename.

put stream stOrd unformatted
"hello" + "kidda"
skip.

output stream stOrd close.


when outputting using the filename is does not create the file. But if i do the following it works fine? why is this?


output stream stOrd to c:\test.txt.


this line works fine and creates the file

hope someone can assist

cheers
TJ
 

banana

New Member
Hi

I am trying to output to a file using PUT statement but it does not seem to work. Basic code below:

--------------------------------------------------------------------------------
def var filename as char no-undo.

DEFINE STREAM stOrd.

filename = "invSara" + TRIM(STRING(day(TODAY))) +
TRIM(STRING(month(TODAY))) + TRIM(STRING(year(TODAY))) + ".txt".

output stream stOrd to filename.

put stream stOrd unformatted
"hello" + "kidda"
skip.

output stream stOrd close.


when outputting using the filename is does not create the file. But if i do the following it works fine? why is this?


output stream stOrd to c:\test.txt.

this line works fine and creates the file

hope someone can assist

cheers
TJ


Tries to place the complete PATH in the variable filename.

Example:

filename = "c:\invSara" + TRIM(STRING(day(TODAY))) +
TRIM(STRING(month(TODAY))) + TRIM(STRING(year(TODAY))) + ".txt".

bye, lucky!!
 

tjsingh

Member
hi

is it the same in unix?

filename = "/test/" + "invSara" + TRIM(STRING(day(TODAY))) +
TRIM(STRING(month(TODAY))) + TRIM(STRING(year(TODAY))) + ".txt".
 

sunilnair

Member
output stream str1 to value(filename) will work as well ....

it will not work if you just "output to variable" , it will work only if you "output to Value(variable)" ....
 

sphipp

Member
output stream stOrd to filename will create a file called filename which is probably in your start directory.

The reason that output stream stOrd to c:\test.txt works is that you have specified the filename as a single text word, if you had used output stream stOrd to c:\test file.txt then it wouldn't have worked.

The first example treats filename as text.

I tend to use value for any input/output operations.
 
Top