Highlighted
Absent Member.
Absent Member.
1711 views

GO TO statement in winform

Jump to solution

I am trying to use GO TO statement to change the program flow of the main program which controls my winform screen execution.

But VS 2013 throws below error even though i have declared the procedure name.

Error 73 COBCH0301 : Unrecognized verb 
Error 74 COBCH0348 : Procedure name ASFFSAFGHAHSDHG undeclared, line 50 (first usage) 

EX:

procedure division.

invoke type System.Windows.Forms.Application::EnableVisualStyles()
set FormSTKR to new WI100.STICKERSCR()
invoke type System.Windows.Forms.Application::Run(FormSTKR)

set mainForm to new WI100.WI10000SCR(FormSTKR)
invoke type System.Windows.Forms.Application::Run(mainForm)

set Form10010 to new WI100.WI10010SCR(mainForm)
invoke type System.Windows.Forms.Application::Run(Form10010)

if Form10010::ScrXmit = "X"
go to mainmenu-screen      ------> error 74
end-if

mainmenu-screen.               -------> error 73
if true
display "test"
end-if

goback.

end method.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

In this example you still need to place a period before the new procedure name.

 invoke type System.Windows.Forms.Application::Run(FormSTKR).    *> add period here

main-menu-screen.

\Can I recommend that you modify this piece as follows: I am n ot sure if you really want a new instance of your forms each time thru the loop but I left it that way.

       set FormSTKR to new WI100.STICKERSCR()
       invoke type System.Windows.Forms.Application::Run(FormSTKR)

           *> main-menu-screen.

        perform until exit
             set mainForm to new WI100.WI10000SCR(FormSTKR)
             invoke type System.Windows.Forms.Application::Run(mainForm)
             set Form10010 to new WI100.WI10010SCR(mainForm)
             invoke type System.Windows.Forms.Application::Run(Form10010)
             if Form10010::ScrXmit not = "X"
                exit perform
             end-if.    
         end-perform

         goback.

     end method.

     end class.

View solution in original post

0 Likes
7 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

You would need to place a period after the last statement of your if statement so that the new paragraph name starts after the period.

if Form10010::ScrXmit = "X"

go to mainmenu-screen

end-if.     *> add period here.

mainmenu-screen.

But even without the period I do not get the error that you are seeing.

What version of Visual COBOL are you using?

I am testing with Visual COBOL 2.3 update 1.

That being said, please do NOT use a GO TO statement within a method. It is really bad programming practice. It would be much better to divide your class up into methods instead of paragraphs and then use invoke syntax to execute them.

If you must use paragraphs or sections within a method then I would recommend using a PERFORM statement instead of a GO TO. Depending on the complexity of your code you might be able to get away with just using in-line performs instead of performing paragraphs altogether.

I am sure that others may have an alternate opinion on this subject, but I just thought that I would share mine.

Thanks.

0 Likes
Highlighted
Absent Member.
Absent Member.

I did try with period after end-if. As an example i have shared the sample code, in real my procedure statement is prior to IF condition.

I think the problem is in procedure or paragraph name declaration. Even perform statement gives me the same error.

These changes are being made in the main program which executes the winforms in my project solution.

I am using Visual cobol 2.2 and visual studio 2013.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Can you show me what the actual code look likes?

0 Likes
Highlighted
Absent Member.
Absent Member.

      class-id WI100.WI100PGM.

      method-id Main static

          attribute System.STAThread.

      local-storage section.

      01 mainForm type WI100.WI10000SCR.

      01 Form10010 type WI100.WI10010SCR.

      01 Form10015 type WI100.WI10015SCR.

      01 Form10015TAX type WI100.WI10015TAX.

      01 Form10020 type WI100.WI10020SCR.

      01 Form10030 type WI100.WI10030SCR.

      01 Form10030C type WI100.WI10030CSCR.

      01 Form10040 type WI100.WI10040SCR.

      01 Form10050 type WI100.WI10050SCR.

      01 Form10060 type WI100.WI10060SCR.

      01 Form10060T type WI100.WI10060TAX.

      01 Form10090 type WI100.WI10090SCR.

      01 FormSTKR  type WI100.STICKERSCR.

      01 FormERR   type WI100.ERRSCR.

      procedure division.

          set Form10015 to new WI100.WI10015SCR()

          set Form10015TAX to new WI100.WI10015TAX()

          set Form10020 to new WI100.WI10020SCR()

          set Form10030 to new WI100.WI10030SCR()

          set Form10030C to new WI100.WI10030CSCR()

          set Form10040 to new WI100.WI10040SCR()

          set Form10050 to new WI100.WI10050SCR()

          set Form10060 to new WI100.WI10060SCR()

          set Form10060T to new WI100.WI10060TAX()

          set Form10090 to new WI100.WI10090SCR()

          set FormERR  to new WI100.ERRSCR()

          invoke type System.Windows.Forms.Application::EnableVisualStyles()

          set FormSTKR to new WI100.STICKERSCR()

          invoke type System.Windows.Forms.Application::Run(FormSTKR)

       main-menu-screen.

          set mainForm to new WI100.WI10000SCR(FormSTKR)

          invoke type System.Windows.Forms.Application::Run(mainForm)

          set Form10010 to new WI100.WI10010SCR(mainForm)

          invoke type System.Windows.Forms.Application::Run(Form10010)

          if Form10010::ScrXmit = "X"

             perform  main-menu-screen      *> OR GO TO main-menu-screen      

          end-if.

          goback.

      end method.

      end class.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

In this example you still need to place a period before the new procedure name.

 invoke type System.Windows.Forms.Application::Run(FormSTKR).    *> add period here

main-menu-screen.

\Can I recommend that you modify this piece as follows: I am n ot sure if you really want a new instance of your forms each time thru the loop but I left it that way.

       set FormSTKR to new WI100.STICKERSCR()
       invoke type System.Windows.Forms.Application::Run(FormSTKR)

           *> main-menu-screen.

        perform until exit
             set mainForm to new WI100.WI10000SCR(FormSTKR)
             invoke type System.Windows.Forms.Application::Run(mainForm)
             set Form10010 to new WI100.WI10010SCR(mainForm)
             invoke type System.Windows.Forms.Application::Run(Form10010)
             if Form10010::ScrXmit not = "X"
                exit perform
             end-if.    
         end-perform

         goback.

     end method.

     end class.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

Thanks Chris.

A period before procedure name resolved the error. I will consider your code change. Thanks once again.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

I just noticed that in my example I gave to you there is an extra period after the end-if that should not be there:

Should be:

         perform until exit
            set mainForm to new WI100.WI10000SCR(FormSTKR)
            invoke type System.Windows.Forms.Application::Run(mainForm)
            set Form10010 to new WI100.WI10010SCR(mainForm)
            invoke type System.Windows.Forms.Application::Run(Form10010)
            if Form10010::ScrXmit not = "X"
               exit perform
            end-if
        end-perform

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.