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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print New Line

Status
Not open for further replies.

umapathi72

Programmer
Jan 16, 2008
4
GB
Hello experts
in my 4gl file
I need to print some file names
like resi,busi,cyta etc in some .txt file
they need to be displayed in new line

resi
busi
cyta
..etc

can somebody help me to print new lines in 4gl file coding

Thanks




 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
There are numerous ways of creating text files in 4GL. Perhaps the most straightforward say is to create a 4GL report printig just one line, and sending the report to a file:

Code:
MAIN

START REPORT my_report TO "/tmp/file.txt"

OUTPUT TO REPORT my_report ("resi")
OUTPUT TO REPORT my_report ("busi")
OUTPUT TO REPORT my_report ("cyta")

FINISH REPORT my_report

END MAIN

REPORT my_report (output_line)
   DEFINE
      output_line CHAR(30)

OUTPUT
   PAGE LENGTH 1
   TOP MARGIN 0
   LEFT MARGIN 0
   BOTTOM MARGIN 0

FORMAT
   ON EVERY ROW
      PRINT COLUMN 1, output_line

END REPORT

Another way is to build a unix command such as echo'ing a string to a file, and using the 4GL RUN command to execute:

Code:
DEFINE output_file CHAR(25)

MAIN

DEFINE string CHAR(100)

LET output_file = "/tmp/file.txt"
LET string = "rm -f ", output_file cLIPPED
RUN string

LET string = build_command("resi")
RUN string

LET string = build_command("busi")
RUN string

LET string = build_command("cyta")
RUN string
END MAIN

FUNCTION build_command(file_name)
   DEFINE
      file_name CHAR(30),
      str CHAR(100)

LET str = "echo \"", file_name CLIPPED, "\" >> ", output_file CLIPPED
RETURN str

END FUNCTION
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top