Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write a log file in 4gl

Status
Not open for further replies.

patriceguic

Programmer
Feb 26, 2007
2
FR
Hello,

I want to write a file during the execution of my 4ge.
I don't know how open and write into a file.

thank for your reply.
 
There are three typical ways of creating log files in Informix 4GL:

1) After a call to the Informix startlog function:

Code:
call startlog("/path/to/errorfile")

You can then append any text using the errorlog function to /path/to/errorfile :

Code:
call errorlog("my test line")

2) You can use the Informix 4GL REPORT option:

Code:
# untested
START REPORT errReport TO "/path/to/myerrorfile"
OUTPUT TO REPORT errReport("a string of text")
FINISH REPORT errReport

Your errReport might look like this:

Code:
REPORT errReport(p_errMsg)
DEFINE  p_errMsg CHAR(80)

    ON EVERY ROW
    PRINT column 2, p_errMsg
END REPORT

The drawback of the REPORT option is it truncates the file when the REPORT is started.

3) You can input text into a database table and then unload to a file using the Informix 4GL unload syntax. I think that is dumb for this case, so I won't even cover it.

Finally, there's a 4th way; I've created a FAQ over in the IBM: Informix Dynamic Server forum:

faq179-2007

The FAQ describes "C" functions that let you interact with the Unix OS. This includes reading and writing to disk files "on the fly". You really don't have to be a "C" programmer to use them. Just link them into your code and call them correctly.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top