1

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 `CALL ch_in.close()` statement in the I4GL (as opposed to Genero) code is presumably a typo of some sort. – Jonathan Leffler Nov 11 '20 at 14:56
  • The message 'Permission denied' usually corresponds to `errno == EPERM`, but it is also a very common exit status for programs that do not succeed. I think you should probably conclude that the 'permission denied' error is really the exit status from the programs you're running. It suggests that the program generated didn't compile. It probably isn't anything to do with file permissions, though there is an outside chance that it is also that. – Jonathan Leffler Nov 11 '20 at 14:57
  • Yes @Jonathan, `CALL ch_in.close()` was a typo only in I4GL. I had an idea that it's not due to file permission, but for some reason it's not writing to the .4gl file. – Roweida February Nov 12 '20 at 10:30
  • I don't understand the use of base.Channel in your sample, but I run your code and it has not given me any error. As noted by Jonathan Leffler there must be a problem with your generated code. – Jeroni Chamorro Nov 12 '20 at 13:15
  • The `LET ch_in = base.Channel.create()` and `CALL ch_in.openFile(p_binoutput,'w')` was just a checkpoint to see if it at least creates/writes to the .4gl extension before it starts the `rpt1()` report to the .4gl. It already denies permissions at the checkpoint, the code doesn't fail just yet at `CALL ch_in.openFile(p_binoutput,'w')`, it still continues even though it's permission is denied. It Denies permissions again when it starts the report. It crashes only when it `output to reports`. I checked again, it does even get a chance to run through the program that it generates. – Roweida February Nov 13 '20 at 11:00

1 Answers1

1

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.

fourjs.reuben
  • 286
  • 3
  • 3