Skip to main content

Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

The Tic-tac-toe exmple is most likely the one from the Micro Focus product line like Net Express and Visual COBOL and not for Acubench.

I am placing this thread into the ACU forum and maybe they can recommend a good example program for you.

Thanks.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Why don't you start with the Acu examples ...Open AcuBench, choose open workspace ... navigate to  C:\\Program Files (x86)\\Micro Focus\\Acucbl911\\AcuGT\\sample\\acubench and select samples.pjt. That will provide 4 project, some basic COBOL examples, some graphical.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

I thought I would add the the tictac sample is made to use with ADIS ... note the call clear-screen syntax .. ADIS is not part of the Acu User Interface syntax. Look at the Acu sample calculat.cbl for a simple display / accept. Look at CALC3.CBL for how Acu provides graphical controls. Tour.cbl also shows Acu style graphical controls.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

g


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Alright, you are close. COBOL as far as text has two formats, ANSI, which yours is close to, and terminal. ANSI format has the COBOL starting in column 8, many of your COBOL statements start in column 7 which is a comment area for ANSI. You also used a reserved word "CELL". As acu supports graphical syntax, we reserve the word cell for designating how large a cell (think pixel) can be. You also used the COBOL verb SET, when you should use MOVE. Lastly, you have two programs posted. While Micro Focus supports nested programs, Acu does not, you need to compile TicTacToe and Formatcell separately. Here is TicTacToe formatted correctly with the changes made for CELL and SET.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

      IDENTIFICATION DIVISION.

      PROGRAM-ID.  TicTacToe.

      DATA DIVISION.

      WORKING-STORAGE SECTION.

      01 CurrentPlayer     PIC A VALUE "X".

      01 CurrentMove       PIC 9(10).

      01 RowSeparator      PIC X(11) VALUE "--- --- ---".

     * The board, for calculation purposes

      01 CurrentBoard.

         02 CurrentBoardValues        PIC X(9) VALUE "123456789".

         02 CurrentBoardTable REDEFINES CurrentBoardValues.

             03 Cell-1 OCCURS 9 TIMES PIC X.

     * The board, for display purposes

      01 BoardForDisplay.

         02 BoardValuesForDisplay.

             03 RowOne        PIC X(11) VALUE "(1)|(2)|(3)".

             03 FILLER        PIC X.

             03 RowTwo        PIC X(11) VALUE "(4)|(5)|(6)".

             03 FILLER        PIC X.

             03 RowThree      PIC X(11) VALUE "(7)|(8)|(9)".

             03 FILLER        PIC X.

         02 FILLER REDEFINES BoardValuesForDisplay.

             03 DisplayCell   OCCURS 9 TIMES PIC X(4).

      01 GameOver          PIC X VALUE 'F'.

      PROCEDURE DIVISION.

      Begin.

          PERFORM WITH TEST AFTER UNTIL GameOver EQUAL 'T'

             PERFORM DisplayBoard

             DISPLAY "Select a square, " CurrentPlayer ": "

                 WITH NO ADVANCING

             ACCEPT  CurrentMove

             IF CurrentMove > 0 AND CurrentMove < 10 AND

                     Cell-1(CurrentMove) NUMERIC

                 MOVE CurrentPlayer TO Cell-1(CurrentMove)

                 CALL "FormatCell" USING BY CONTENT CurrentPlayer

                     BY REFERENCE DisplayCell(CurrentMove)

                 PERFORM CheckForWin

                 PERFORM CheckForDraw

                 PERFORM SwitchPlayer

             END-IF

          END-PERFORM.

          STOP RUN.

      DisplayBoard.

          DISPLAY " "

          DISPLAY RowOne

          DISPLAY RowSeparator

          DISPLAY RowTwo

          DISPLAY RowSeparator

          DISPLAY RowThree

          DISPLAY " ".

      CheckForWin.

          IF Cell-1(1) EQUAL cell-1(2) AND cell-1(2) EQUAL cell-1(3)

            OR cell-1(4) EQUAL cell-1(5) AND cell-1(5) EQUAL cell-1(6)

            OR cell-1(7) EQUAL cell-1(8) AND cell-1(8) EQUAL cell-1(9)

            OR cell-1(1) EQUAL cell-1(4) AND cell-1(4) EQUAL cell-1(7)

            OR cell-1(2) EQUAL cell-1(5) AND cell-1(5) EQUAL cell-1(8)

            OR cell-1(3) EQUAL cell-1(6) AND cell-1(6) EQUAL cell-1(9)

            OR cell-1(1) EQUAL cell-1(5) AND cell-1(5) EQUAL cell-1(9)

            OR cell-1(3) EQUAL cell-1(5) AND cell-1(5) EQUAL cell-1(7)

             PERFORM DisplayBoard

             DISPLAY CurrentPlayer " Wins!"

             Move 'T' TO GameOver

           END-IF.

      CheckForDraw.

          IF CurrentBoard ALPHABETIC AND GameOver NOT EQUAL 'T'

             PERFORM DisplayBoard

             DISPLAY "It's a Draw!"

              Move 'T' TO GameOver

          END-IF.

      SwitchPlayer.

          IF CurrentPlayer EQUAL "X" THEN

             Move "O" TO CurrentPlayer

          ELSE

             Move "X" TO CurrentPlayer

          END-IF.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

It appears that when posting text here in forum, a column is lost. The main COBOL should start in column 8, comments in column 7 and procedure code (like the IF and performs) in column 12.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

thank you so much it run but it still dont work thers just the field an it appears select a square but if i select a square or anyting else nothing happens


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

thank you so much it run but it still dont work thers just the field an it appears select a square but if i select a square or anyting else nothing happens


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

thank you so much it run but it still dont work thers just the field an it appears select a square but if i select a square or anyting else nothing happens


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

I compiled these programs and ran in debug.

I noticed for some strange reason the field CurrentMove is acting like an alpha-numeric field.

Accepting this field yields (in hex) 31202020202020202020.

This is causing the following to be false:

             IF CurrentMove > 0 AND CurrentMove < 1

                     Cell-1(CurrentMove) NUMERIC  

Change the pic for CurrentMove  as follows:

      01 CurrentMove       PIC 9.

Then recompile


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Try adding the CONVERT phrase to the ACCEPT, or alternatively, compile with the -Vc option (which has the same effect, implying CONVERT on all ACCEPTs).

What is happening is there's an ACCEPT of a PIC 9(10) field, but you only enter a single digit. Without the CONVERT phrase, the field is left-justified and the remainder of the digits remain spaces. This fails the NUMERIC test (or possibly the less-than/greater-than test) done on CurrentMove. With the CONVERT phrase, the field is automatically right-justified and spaces convert to zeroes, because the receiving field is numeric.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Two things .. now that it compiles, you can run this program in the degugger. This would allow you to step through each line of code, double click on variables to see their values. I noticed this code doesn't process like I think you want it to:

               IF CurrentMove > 0   AND CurrentMove < 10

               AND Cell-1(CurrentMove) NUMERIC

                MOVE CurrentPlayer TO Cell-1(CurrentMove)

I noticed that you had defined Cell-1 as pic X and even if you move a number to a pic X it will not evaluate as numeric. I also believe that you are not doing this statement correctly ...

 MOVE CurrentPlayer TO Cell-1(CurrentMove)


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Another note - instead of renaming CELL to CELL-1, you could tell the compiler to NOT treat CELL as a reserved word. Do this by adding "-Rw CELL" to your compile options.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

thank you so much it works


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

one last problem. the window is closing directly after the game. i cant read if i won or if its a draw how can i solve these last problem


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

one last problem. the window is closing directly after the game. i cant read if i won or if its a draw how can i solve these last problem


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

one last problem. the window is closing directly after the game. i cant read if i won or if its a draw how can i solve these last problem


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Add an ACCEPT OMITTED statement just before the STOP RUN.  This will stop execution at that point, allowing you to see the screen.  Once you hit Enter, the program will continue to the STOP RUN statement and then exit.

Note that ACCEPT OMITTED is ACUCOBOL-specific syntax.  For greater portability (i.e. to other COBOL compilers), create a data item in Working-Storage:

   77 DUMMY-VAR PIC X.

Then accept it, just before the STOP RUN:  

   ACCEPT DUMMY-VAR.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

its me again now i want to try to build a GUI for the tictactoe program. im not sure if i should use entry fields or maybe push-buttons or something else? is it possible to click on a push button and it gets automatically the value X or O like in the switchplayer procedure? and how do i get all the changes into my code are there many things to change?


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Push buttons sound good, nice Tac Tac Toe box size. Place a different exception value for each box. Everytime a push btton is clicked, your program receives the exception value. When a Push button is selected, load a nice bitmap (that has an X or an O) onto the push button. That should give you a nice look.


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

Thanks a lot for your answer i try it with the push buttons. is it possible to get a modus to play vs a computer how do i realize that the computer play with a strategy and not random


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

im absolutly new in programming cobol so my problem how should i get the different exception values? with paragraph but how does it work an what do i have to change on the old code to make it possible to switch player maybe i need an example of one button. the samples doesnt work


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

im absolutly new in programming cobol so my problem how should i get the different exception values? with paragraph but how does it work an what do i have to change on the old code to make it possible to switch player maybe i need an example of one button. the samples doesnt work


Hey,

I startet learning cobol and get some problems withhin. To get in touch with the new language i wanted to run a sourcecode from the internet just to get a plan how cobol works. Now to the problem i got the code from a simple tictactoe game copied into the acubench but it doesnt work there are so many errors. did anyone of you could send me a working sourcecode from tictactoe for acubench.

im absolutly new in programming cobol so my problem how should i get the different exception values? with paragraph but how does it work an what do i have to change on the old code to make it possible to switch player maybe i need an example of one button. the samples doesnt work