ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

the STUPID "An assignment operator is expected with the EVAL operation."

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • the STUPID "An assignment operator is expected with the EVAL operation."

    It looks like this error is popping up when it wants to and goes away when it wants to. I have been struggling with this error ever since I started learning rpgle. When I go into the program and change some lines, it throws this error. While the error is still present, I save the program and exit out. I go back in, THE ERROR IS GONE. If I go to the line of error and put a space in it, the error appears again. So over the past few months or so, I've learned to ignore this error because it seems like the program does fine in compiling and running even with this error. It does not create any sev 10+ errors and it does not appear in my spool file report. I am having this error again but this time, it is labeled as a sev 30 error and I just about had enough of it. So I ask the question: what is this error and why does this happen only sometimes, how do I get rid of it????

  • #2
    "Popping up" where? In the editor? In which case _which_ editor. In the compiler listing?

    The usual cause of this (when it is a real error) is a missing semi-colon at the end of the previous line or something equally silly.

    I have never seen it "popping up" randomly and disappearing with no source changes made.

    Comment


    • #3
      Originally posted by JonBoy View Post
      "Popping up" where? In the editor? In which case _which_ editor. In the compiler listing?

      The usual cause of this (when it is a real error) is a missing semi-colon at the end of the previous line or something equally silly.

      I have never seen it "popping up" randomly and disappearing with no source changes made.

      it is popping up inside the program. so
      for example: DCL-S x packed(2:0);
      the cursor points to the "-" with the error. once I save the program, exit, and come back in, no error. if I put a space, in an empty area on that line, lets say after the semi-colon and press enter, the error pops up. One thing I noticed is, the cursor is always pointing to the spot of the fourth character. so in DCL-S, the - is the fourth spot. same with other parts of the program that has the same error. it's as if pressing enter on that line triggers the error, and if I exit and re-enter, the error goes away until I press enter on that line.

      if I am using a different command like CPYF for copying files, the cursor points to the F with the same error. strange thing about this is if the CPYF command is by itself, without any required arguments, no error. if I put in the whole CPYF FROMFILE(FILENAME) TOFILE(FILENAME) and so on, there will be an error on the F of CPYF. thats why it's driving me nuts because to me, it seems like there is no reason...I thought it would atleast ask for the required arguments...

      Comment


      • #4
        Originally posted by skwon9642 View Post
        for example: DCL-S x packed(2:0);
        It sounds like you're using SEU. SEU has been stabalised so it doesn't understand the free-form D specs. As such, they will get highlighted as you describe but only when you change it or add a new one because as far as I'm aware, SEU only syntax checks lines when you insert/change them.

        if I am using a different command like CPYF for copying files, the cursor points to the F with the same error. strange thing about this is if the CPYF command is by itself, without any required arguments, no error. if I put in the whole CPYF FROMFILE(FILENAME) TOFILE(FILENAME) and so on, there will be an error on the F of CPYF. thats why it's driving me nuts because to me, it seems like there is no reason...I thought it would atleast ask for the required arguments...
        This must be a CL program as CPYF isn't an RPG command so hard to know why the error unless you post the code for this line and the ones around it.
        Last edited by john.sev99; August 2, 2017, 03:04 PM.

        Comment


        • #5
          Originally posted by john.sev99 View Post
          It sounds like you're using SEU. SEU has been stabalised so it doesn't understand the free-form D specs. As such, they will get highlighted as you describe but only when you change it or add a new one because as far as I'm aware, SEU only syntax checks lines when you insert/change them.


          This must be a CL program as CPYF isn't an RPG command so hard to know why the error unless you post the code for this line and the ones around it.
          I had no idea CPYF was a CL command...I looked up how to duplicate files from one library to another and it popped up. I have fixed it to CRTDUPOBJ, still same error with that command,
          I have attached some pictures of the errors and then the same code without errors. The errors appear only after putting a space or doing any edits on the line(I circled where I put a space which led to the error).


          Attached Files

          Comment


          • #6
            pic of the CRTDUPOJB command without error, before editing that line.

            and a pic of the spool file report. In this case, there was no error when I pressed enter, but when I compile, there is a sev 30 error. which is the same error as we are discussing here...
            Attached Files

            Comment


            • #7
              For your screen shots of the DCL* statements. As mentioned SEU has been stabalised at v6r1. No further enhancements have been made to it, as such it doesn't understand the newer DCL-S, DCL-PI etc etc freeform D specs and will highlight them as you have shown. It will also not understand newer BIFs so will highlight them as well. IBM suggest people move to RDi which is being updated and understands these newer constructs. Your program will compile OK because the compiler understands these, but the SEU editor does not. There is nothing you can do about this. For the DCL* statements, you could go back to the old style D spec syntax which SEU understands to get rid of the eye burning highlights.

              To your CRTDUPOBJ/CPYF commands. I am confused now - is this an RPG program or a CL program?
              RPG does not understand CL commands so attempting to use them will fail. A CL command is something you can type on a command line and RPG does not natively run these. You could put these commands into a CL module and call the module, or call it using the QCMDEXC or similar API. SEU will correctly highlight this as an error if you try to modify the line.

              Comment


              • #8
                Originally posted by john.sev99 View Post
                For your screen shots of the DCL* statements. As mentioned SEU has been stabalised at v6r1. No further enhancements have been made to it, as such it doesn't understand the newer DCL-S, DCL-PI etc etc freeform D specs and will highlight them as you have shown. It will also not understand newer BIFs so will highlight them as well. IBM suggest people move to RDi which is being updated and understands these newer constructs. Your program will compile OK because the compiler understands these, but the SEU editor does not. There is nothing you can do about this. For the DCL* statements, you could go back to the old style D spec syntax which SEU understands to get rid of the eye burning highlights.

                To your CRTDUPOBJ/CPYF commands. I am confused now - is this an RPG program or a CL program?
                RPG does not understand CL commands so attempting to use them will fail. A CL command is something you can type on a command line and RPG does not natively run these. You could put these commands into a CL module and call the module, or call it using the QCMDEXC or similar API. SEU will correctly highlight this as an error if you try to modify the line.
                That explains the errors I am getting. GREAT, thank you! I am writing a RPGLE program, SQLRPGLE to be more precise. I was using CPYF not knowing that it is a CL command. I looked up how to duplicate files from one library to another and found CRTDUPOBJ would do the trick...am I wrong?

                Comment


                • #9
                  Originally posted by skwon9642 View Post
                  I am writing a RPGLE program, SQLRPGLE to be more precise. I was using CPYF not knowing that it is a CL command. I looked up how to duplicate files from one library to another and found CRTDUPOBJ would do the trick...am I wrong?
                  Both will work to copy a file but they are CL commands. You seem to be confusing CL commands with RPG language statements. CL commands are the commands you type on a command line in an interactive session. You can type CPYF or CRTDUPOBJ on a command line and press F4 to show the parameters. RPG is not a CL interpreter though so does not understand these commands as they are not part of the RPG language. There are several ways to execute a CL command in RPG though.

                  You could put your CL commands in a CLLE source member, compile it as a module and create your program from both your SQLRPGLE and CLLE modules and call the CLLE module from your SQLRPGLE program.
                  You could use the QCMDEXC API to call the CL command.

                  In this case though, as you are just trying to duplicate a file, you could create your file using SQL - CREATE TABLE lib/file AS (SELECT * FROM lib/file) WITH DATA.
                  Last edited by john.sev99; August 2, 2017, 08:20 PM.

                  Comment


                  • #10
                    To add some clarification to what john.sev99 said:

                    Anything you see described as a "command" is generally a CL command. They are always structured like
                    COMMAND PARM1(VALUE1) PARM2(VALUE2 VALUE3)
                    So their syntax made it reasonably obvious they are commands and not RPG code.
                    RPG uses "Opcodes" and "Built-in Functions" (BIFs). E.g.:
                    EVALR ABCD = %CHAR(DEFG)
                    EVALR is an Opcode and %CHAR is a BIF. BIFs always start with a %
                    That should help you understand if you are looking at CL commands or RPG code.

                    You can write and compile a CL program (source member with the CL or CLLE type - CLLE is better) - this is a program that consists of just CL commands. It's a bit like a Windows batch file except it is compiled, rather than interpreted.
                    Your SQLRPGLE program can then call the CL program to execute any CL commands you need.
                    john.sev99's suggestion does the same thing, but a bit more complicated accomplish - compile your SQLRPGLE source and CLLE source as modules rather than programs, and bind them into a single program. This makes for faster execution, but that complexity may not be worth it for you since you are still learning.

                    There is also the QCMDEXC API (Google it), which is an API you can call from within an SQLRPGLE program - you assemble a string containing the required CL command and pass it to the API, and it runs it for you. Some of the API usage examples on this website include the use of QCMDEXC: http://www.code400.com/inside.php?category=API


                    Finally, about the syntax errors you are getting trying to edit DCL-S lines in SEU. As john.sev99 already said, IBM stopped updating the syntax validator in SEU a while ago, and it does not recognise the free-format definition code DCL-*, nor any other enhancements IBM have made to the RPG language in the last few years (changes from OS version v7 and on are unsupported in SEU).
                    IBM now concentrates on improving IBM Rational Developer for i, which is a full Integrated Development Environment for iSeries development. It's a graphical application that is available for Windows, Linux and Mac. If you can move to it, you should - it's code editor is far superior.
                    But if you have to use SEU, you can turn off its syntax validating: while in SEU, hit Shift-F1 (F13) to go to SEU default settings, and under "Syntax checking" change "When added/modified" to N and hit enter. Then at least you won't get the errors while you are editing.

                    Comment

                    Working...
                    X