Highlighted
Absent Member.
Absent Member.
2295 views

[archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

[Migrated content. Thread originally posted on 03 March 2010]

Hi Friends,

I unable to add an ActiveX control. I am getting some compilation errors. So I tried the following to make a timer like control in AcuCOBOL GT.

Please follow the steps.

1) Place a Web Browser control in a Form.
2) Set URL to auto_refresh_1.html
3) In Wb-Title-Change Event Place your code


auto_refresh_1.html




Refreshing.. 2




auto_refresh_2.html




Refreshing.. 1



I need to view the users who are all logged in to the system. And that needs to be refreshed in each 5 seconds.

If you have any alternative, Please suggest me.

-- Mano
0 Likes
11 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

Hi,

Not exactly sure what you're trying to achieve. But if you just want to perform something every 5 seconds you could just place a CALL "C$SLEEP" 5000 at the end of the loop.

regards,
Hans
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

Thanks.

I just want to refresh the Grid for every 5 seconds to moniter the users. And I don't think Sleep will solve my problem.

Because, I should be able to perform some other actions like selecting the Grid, Killing the users session and etc.,

But I don't think it is possible if i use "SLEEP".

-- Mano
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

You could always start a new thread and call sleep in the new thread. That would let you do other stuff whille that thread is running. When the thread returns you know it is time to whatever you want to do every n seconds.

regards,
Hans
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

Thanks.

I think this will work.

-- Mano
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

Here is a little routine we use to accomplish exacly this (refresh a grid every X seconds or minutes).

   
*** In the after create call the Procedure as follows:

       PERFORM THREAD A000-UPDATE-GRID THRU A000-EXIT
                    HANDLE WS-UPDATE-HANDLE.

**********************************************************
*******    Thread to perform the refresh of the grid at regular intervals
**********************************************************
       A000-UPDATE-GRID.
           MOVE ZEROS  TO WS-SECONDS, WS-TEMP-MINS, WS-TEMP-SECS,
                          WS-REFRESH-LENGTH.
           MOVE SPACES TO WS-REFRESH-TIME-TYPE.

           | how often to refresh the list
           | Default to every 5 MIN if nothing setup
           IF WS-REFRESH-LENGTH = SPACES OR ZEROS
              MOVE 5     TO WS-REFRESH-LENGTH
           END-IF.
           IF WS-REFRESH-TIME-TYPE = SPACES
              MOVE "MIN" TO WS-REFRESH-TIME-TYPE
           END-IF.
           | convert to seconds to display on screen
           | properly counting down
           IF WS-REFRESH-TIME-TYPE = "MIN"
              COMPUTE WS-SECONDS = WS-REFRESH-LENGTH * 60
           ELSE
              MOVE WS-REFRESH-LENGTH TO WS-SECONDS
           END-IF.
       A000-REFRESH.
           | in the middle of refreshing the grid, this will clear once done.
           IF REFRESH-TYPE NOT = SPACES
              CALL "C$SLEEP" USING 1
              GO TO A000-REFRESH
           ELSE
              SET AUTO-REFRESH TO TRUE
              MOVE "Refresh in: Now" TO ws-panel-text
              MODIFY Screen1-St-1-Handle, PANEL-INDEX 1
                             PANEL-TEXT ws-panel-text
              PERFORM X000-RELOAD-GRID THRU X000-RELOAD-EXIT
           END-IF.
           MOVE ZEROS TO CTR.
           PERFORM VARYING TIME-CTR FROM WS-SECONDS BY -1
                                                UNTIL TIME-CTR = 0
               | Display the countdown
               DIVIDE 60 INTO TIME-CTR GIVING WS-TEMP-MINS
                                    REMAINDER WS-TEMP-SECS
               PERFORM WITH TEST AFTER UNTIL NOT AUTO-REFRESH-PAUSED
                  | If Paused display Paused else display countdown
                  IF AUTO-REFRESH-PAUSED
                     MOVE "Refresh in: Paused" TO ws-panel-text
                     MODIFY Screen1-St-1-Handle, PANEL-INDEX 1
                              PANEL-TEXT ws-panel-text
                  ELSE
                     MOVE SPACES TO ws-panel-text
                     MOVE WS-TEMP-MINS TO SM-DISP-HOUR
                     MOVE WS-TEMP-SECS TO SM-DISP-MIN
                     MOVE SPACES       TO SM-DISP-AMPM
                     STRING "Refresh in: ", SM-DISP-TIME
                          DELIMITED BY SIZE INTO ws-panel-text
                     END-STRING
                     MODIFY Screen1-St-1-Handle, PANEL-INDEX 1
                                   PANEL-TEXT ws-panel-text
                  END-IF
                  | Display current server time
                  ACCEPT WS-TIME FROM TIME
                  MOVE "AM"      TO SM-DISP-AMPM
                  IF WS-HOUR > 11
                     SUBTRACT 12 FROM WS-HOUR
                     MOVE "PM" TO SM-DISP-AMPM
                  END-IF
                  IF WS-HOUR = ZEROS
                     MOVE 12 TO WS-HOUR                           
                  END-IF
                  MOVE WS-HOUR             TO SM-DISP-HOUR
                  MOVE WS-MIN              TO SM-DISP-MIN
                  MOVE SPACES TO WS-DATE-TIME
                  STRING "Server Time: ", SM-DISP-TIME DELIMITED BY SIZE
                       INTO WS-DATE-TIME
                  END-STRING
                  MODIFY Screen1-St-1-Handle, PANEL-INDEX 2
                                PANEL-TEXT WS-DATE-TIME
                  CALL "C$SLEEP" USING 1
               END-PERFORM
           END-PERFORM.
           SET FIRST-REFRESH TO FALSE.
           GO TO A000-UPDATE-GRID.
       A000-EXIT.
           EXIT.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

This is working fine.

Thank you for your help HansJ & Mikalodeon.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

Now I am facing an issue.

My application is getting closed automatically after some amount of time.

My code:



In After create
**************************
           PERFORM THREAD
                   UPDATE-GRID
              THRU UPDATE-GRID-EXIT
              HANDLE WS-UPDATE-HANDLE.
******************************



       UPDATE-GRID.
           CALL "C$SLEEP" USING 10.
           PERFORM REFRESH-GRID
              THRU REFRESH-GRID-EXIT.
           GO TO UPDATE-GRID.
       UPDATE-GRID-EXIT.
           EXIT.


And I am destroying the WS-UPDATE-HANDLE on Closing the screen.

But if i leave the screen open it is automatically getting closed after some amount of time.

I hope this is a kind of stack overflow or something. If anyone have any idea please suggest me.

-- Mano
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

Do you have an accept .... before time somewhere in your program?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

If you are running this via thin client, could be that it's just timing out because of no interactivity...

| This will keep the connection alive for a max of 9 hours
| with no user interactivity. The default is 5 min.
IF IS-REMOTE
SET ENVIRONMENT "TC_CHECK_ALIVE_INTERVAL" TO 32767
END-IF.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

Thanks Dilbert & Mikalodeon..

As I am running this via thin client, the fix is working for me.

Thank you for your help.

-- Mano
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] An Idea to make Timer Control with out any ActiveX Control in AcuCOBOL GT

We simply use accept before time and if it times out we refresh the data on screen and go back to the accept before time.
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.