I have a code in Informix 4gl that creates and writes to .4gl file. In short, it's code that generates a new program. It works perfectly in Informix:**
let p_output = p_prog clipped,".4gl"
start report rpt1 to p_output
output to report rpt1()
finish report rpt1
let run_stmt = "fglpc ",p_prog clipped
run run_stmt returning p_status
if p_status != 0 then
error " Program Compilation failed "
sleep 1
end if
end if
I'm trying to convert the code to Genero to create and write to a .4gl file.
let p_output = "vi ",p_prog clipped,".4gl"
let p_binoutput = p_prog clipped,".4gl"
LET ch_in = base.Channel.create()
CALL ch_in.openFile(p_binoutput,"w")
start report rpt1 TO p_output
output to report rpt1()
finish report rpt1
--let run_stmt = "fglpc ",p_prog clipped
let run_stmt = "fglcomp ",p_prog clipped
run run_stmt returning p_status
if p_status != 0 then
error " Program Compilation failed "
sleep 1
end IF
CALL ch_in.close()
end if
But I keep getting the error message in sqlca.sqlerrm:
p_prog.4gl: Permission denied.
or
vi p_prog.4gl: Permission denied
How can I fix this?
The only code you needed to change moving from Informix-4gl to Genero was the line
let run_stmt = "fglpc ",p_prog clipped
to
let run_stmt = "fglcomp ",p_prog clipped
so that your program used the Genero compiler in its generation and not the Informix 4gl compiler.
There was no need to introduce use of base.Channel methods. That is the preferred way moving forward to read/write files, particularly with non-paged output but the old school START REPORT ... is unchanged and should function as before.
The error messages you see are telling you what it says on the box. I can get it by removing write access to p_prog.4gl so check if the file exists and your user has write permissions.
Another possible gotcha, fglcomp, fglrun function the same as their Informix equivalents with regard to the current working directory and mix source and compiled objects in the same directory. If using Genero Studio, it by default keeps the source and compiled objects in different directories so either alter the TargetDirectory to not use bin, or be aware that with your permissions, file locations etc that at runtime you maybe are in the bin directory.