ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

GOTO statement conversions

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

  • GOTO statement conversions

    Hello all,

    I've fired up Target 400's conversion software and started converting some S/36 code I have (a lot of it--doing one project at a time), starting with OCL. Questions are starting to come as I look over the converted code, first one is GOTO statements. I hate them, but I have so much code that has it in it, I'll most likely have to leave them, unless there is a realitively easy way around it? I'm guessing just let them be, but how? So the conversion puts them as a

    GOTO CMDLBL(XXXXX)
    ...
    ...
    XXXXX
    Line code (// TAGXXXXX) jumps to here...

    Best to laave it as GOTO CMDLBL(XXXXX)? Then handle the tag statemnt as just a command label? Are their any restrictions on the command labels? Can I just leave them however they would be after the tag?

    OCL Example:
    // GOTO CS#01
    // ...
    // ...
    // TAG CS#01
    Line code jumps to here...

    CL conversion:
    GOTO CMDLBL(CS#01)
    ...
    ...
    CS#01
    Line code jumps to here...

    Will leaving the "CS#01" procedure name like it is work fine? I'd love to remove all the goto's but that just isn't really going to happen. So, I'll deal with it as long as that works.

    If anyone has any thoughts going forward I might find useful that has done these conversions or knows about them, feel free to prepare me
    I will be converting every project I touch to modern code OCL > CLLE, RPGII/III > RPG Free, etc.
    I am looking at Linoma, and Arcad as well, but I will be hands on as much as possible considering I don't have a huge budget and it's just me.

    Thanks!
    Programmer/Systems Analyst

  • #2
    I don't think any automated conversion tool is going to remove gotos. Usually, something like this requires re-thinking the structure of a program and then refactoring the code accordingly, which is too much to ask of a conversion program.

    I haven't done this stuff in 20 years, but when I did, my approach was to convert it all to CL and get things up and running. Then, whenever I needed to make a change to a program for any reason, I would refactor it to indent things properly, use better variable names, remove gotos, etc. I would only do it when I needed to change the source for some reason, so some programs would remain using the old style for a very long time simply because they didn't need any changes.

    Comment


    • #3
      Hi Scott,

      I looked around a bit and did not see any useful tools to automate the GOTO, didn't expect to find any, and did not. Anyway, Going forward and expecting to leave them, my quetion is more concerning the syntax. What is the best syntax to leave to GOTO statement as it relates to leaving it and working towards modern CL? In OCL it uses the GOTO with TAG. In modern CL, what can you use to replace this? GOTO XXX, then LBL XXX? I know that the GOTO CMDLBL(XXX) and XXX as the 'tag' will throw an error. (when it's a unique name, like CS#01) Maybe just GOTO XXX, and XXX as the tag, with no LBL reference? I just want to get it to something that will work as I modernize the code off of OCL and stay for as long as needed until I can properly remove them.
      Last edited by RobertHoehle; June 26, 2016, 08:16 AM.
      Programmer/Systems Analyst

      Comment


      • #4
        Update: The syntax includes a colon. So it's
        GOTO CMDLBL(XXX)
        ...
        ...
        XXX:
        and that works fine.

        Now I'm in need of the SRTDTA command added to the library.
        And a couple of other errors, positional value after a CHGVAR and a List item value for parameter TOUSRID required, then I can move on to the next portion...
        Programmer/Systems Analyst

        Comment


        • #5
          Originally posted by RobertHoehle View Post
          Now I'm in need of the SRTDTA command added to the library.
          SRTDTA should already be in a library. What do you mean by "to the library"

          And a couple of other errors, positional value after a CHGVAR...
          What about them? An example would be helpful.

          ... and a List item value for parameter TOUSRID required...
          Again, an example would be helpful. But it seems likely that you only need an extra set of parentheses around it.
          Tom

          There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

          Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

          Comment


          • #6
            I managed to find all the errors for CHGVAR, and TOUSRID, I just need to get SRTDTA working. The command does not show up in the *LIBL and I'm guessing I just need to add it. I had to call it quits for the day, but I will pick it up tomorrow. The error I get is CPD0030, Command SRTDTA in Library *LIBL not found (in RDi). Talking to John at Target400, I was told that I needed to 'activate' it? from the TRG.TOOL library/toolkit. If you know where it is to load it to the *LIBL, please enlighten me. I'll work more on this tomorrow.

            Thanks.
            Programmer/Systems Analyst

            Comment

            Working...
            X