OUTPUT STERAM WITH UNIQUE FILE NAME

HT3

Member
Hi Guys,

My first post on here (Treat me like I've got no idea).

Long story short, I'm looking at existing code that was coded to write and read from multiple files and on occasions from the same files. This is causing issues as users a free to schedule the task\job when ever they want. After numerous attempt's to stop users bunching them together on the queue, they carry on doing so.

I've therefore decided to tackle the code and started de-bugging, with my theory being access to the same files is the cause.

I've tried entering the below into the code (Syntax Check is fine).....

DEFINE VARIABLE cFileName AS CHARACTER FORMAT 'x(57)'.
DEFINE STREAM HT.

ASSIGN cFileName = "\\m25\data\ERPData\PAC\HTDEBUG\test" +
SUBSTRING(STRING(TODAY,"99/99/99"),7,2) +
SUBSTRING(STRING(TODAY,"99/99/99"),4,2) +
SUBSTRING(STRING(TODAY,"99/99/99"),1,2) +
STRING(TIME,"999999") + ".txt". /* 221116453862 */

OUTPUT STREAM HT TO cFileName.

PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Open" + "," + "airfence" + "," SKIP.

PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "OK" + "," + "airfence" SKIP.

PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Close" + "," + "airfence" + ","SKIP.

OUTPUT STREAM HT CLOSE.


However the file isn't created.

It works using the below code.


DEFINE STREAM HT.

OUTPUT STREAM HT TO \\m25\data\ERPData\PAC\HTDEBUG\test.txt.

PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Open" + "," + "airfence" + "," SKIP.

PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "OK" + "," + "airfence" SKIP.

PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Close" + "," + "airfence" + ","SKIP.

OUTPUT STREAM HT CLOSE.



However the second block of code doesn't give me a unique file name which I need so when they run 40 plus instances I've got a record for each one.

I've tried adding the substring section in my first block, directly to the OUTPUT STREAM TO but it fails with the below error message.


1669377639371.png

Any ideas, I would love to fix this solution to learn why it's going wrong rather than a new approach.

Thanks,
Hassam
 

DOKTORF

New Member
Try OUTPUT STREAM HT TO value(cFileName).
and look for a file called cFileName. In your case, progress has created a file called cFileName in its root
 

HT3

Member
@DOKTORF When you say Progress has created a cFileName at it's root what do you mean.

Is it stored else where? besides the path I specified ....
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
Hi Hassam, and welcome. :)
This is causing issues as
with my theory being access to the same files is the cause.
You are alluding to problems (and perhaps error messages?) without stating explicitly what they are. A robust problem definition is essential for finding the appropriate solution.

OUTPUT STREAM HT TO cFileName.
This will create a file with the name "cFileName". You want to output to VALUE( cFileName ).

Also, please enclose your code with [ CODE ] [ /CODE ] tags (without the spaces).
 
Top