Re: [U2] [UV] INPUTTRAP Statement

"Hona, David" <[email protected]>
Newsgroups gmane.comp.db.u2.general
Message-ID <7F9D3D6A1A51A34B91E427507ADF177C3AD932432F@VAUNSW141.au.cbainet.com>
Peter has the right idea. PTERM just does a TTYGET and TTYSET so you can call that directly if you wish. Our legacy code uses "CALL !PTERM('-ERASE ':CHAR(8))" etc. to change TTY characteristics.



I think this "quick n dirty" code snippet could work for you....if you utility is UV/BASIC based you could incorporate this code (maybe!)...



1. Temporary re-define/re-assign the BREAK key then loop for character (decimal) 3...



* Re-define INTR (Break) key so we can 'detect' it

* Assumption is Control-C (Char 3) is the Break Key

* Use TCL PTERM -DISPLAY to check what your BREAK key is set to first ;-)

* David Hona, Jan. 2014

$INCLUDE  UNIVERSE.INCLUDE TTY

      ttyget tty$ then

         if CC.INTR ne 3 then crt "WARNING: BREAK character is currently set to ASCII decimal = ":CC.INTR:" and NOT '3' as expected"

         if CC.INTR then

            crt "Changing to decimal 2 (temporarily)"

            crt "TTY interrupt character = Decimal ASCII = ":CC.INTR

            CC.INTR = 2                  ; * Set to decimal 2 character (Control-B)

            ttyset tty$ then

               crt "TTY interrupt character = Decimal ASCII = ":CC.INTR

            end else

               crt "TTYSET failed!"

            end

         end

      end



      EXIT.FLAG = @FALSE

      prompt ''                          ; * Suppress prompt character



* Now loop for CTRL-C character



      loop



         input BUFFER, -1



         if BUFFER then

            input CHAR, 1

            crt "ASCII = ":seq(CHAR)

            if upcase(CHAR) eq 'Q' then EXIT.FLAG = @TRUE

            if seq(CHAR) eq 3 then

               crt

               crt "CONTROL-C detected!"

               crt

            end

         end



      until EXIT.FLAG do



         nap 500                         ; * Sleep so not to consume all the CPU time



      repeat

*

* Reset back to Control-C

*

      crt "TTY interrupt character = Decimal ASCII = ":CC.INTR

      CC.INTR = 3

      ttyset tty$ then

         crt "Reset back to Control-C"

      end else

         crt "Warning: TTYSET failed. Unable to reset BREAK key back to Control-C"

      end



   end





2. ON.ABORT and @ABORT.CODE



If you are using an external routine (UNIX or Windows scripts) called from UV, then you will have to utilise the ON.ABORT paragraph along with @ABORT.CODE to determine the reason it is being executed. New to UV11.2 is that @ABORT.CODE returns 4 for AUTOLOGOUT events.



There is no way to work out what routine was executing prior to invoking it from what I recall - post-invocation of ON.ABORT.



You could set you own audit trail/transaction logging, setup your own Global Labelled Common variables or just use/set @USER.RETURN.CODE which a paragraph can access. Hence use one or a combo of those to run a clean-up utility invoked via ON.ABORT.



Finally, some care needs to be taken to ensure your external routine/script trapping interrupts (as that'll clash with UV's trap handling)...





Cheers,
David



-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Peter Cheney
Sent: Tuesday, 24 December 2013 9:17 AM
To: U2 Users List
Subject: Re: [U2] [UV] INPUTTRAP Statement



Could you do this via a combination of the PTERM command's BREAK and INTR options along with the ON.ABORT etc?

Something like changing the break from ctrl-C to another key combo during that session?







Peter Cheney

Ultracs Developer

t 07 3017 8837 | f 07 3002 8400

e [email protected]<mailto:[email protected]>

w firstmac.com.au



________________________________________

From: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> on behalf of Perry Taylor <[email protected]<mailto:[email protected]>>

Sent: Tuesday, 24 December 2013 5:41

To: U2-Users List

Subject: [U2] [UV] INPUTTRAP Statement



Has anyone ever used the INPUTTRAP statement in UniVerse BASIC?  I want to be able to trap a break (Ctrl-c) but I can't seem to get it to work with CHAR(3), or any other character for that matter.  The UniVerse BASIC Commands documentation provides no examples on its use.



Anybody done anything like this?  Any sample code you're willing to share?



Thanks.

Perry Taylor

Senior MV Architect

ZirMed

888 West Market Street, Suite 400

Louisville, KY 40202

www.zirmed.com<http://www.zirmed.com/<http://www.zirmed.com%3chttp:/www.zirmed.com/>>



************** IMPORTANT MESSAGE *****************************       
This e-mail message is intended only for the addressee(s) and contains information which may be
confidential. 
If you are not the intended recipient please advise the sender by return email, do not use or
disclose the contents, and delete the message and any attachments from your system. Unless
specifically indicated, this email does not constitute formal advice or commitment by the sender
or the Commonwealth Bank of Australia (ABN 48 123 123 124) or its subsidiaries. 
We can be contacted through our web site: commbank.com.au. 
If you no longer wish to receive commercial electronic messages from us, please reply to this
e-mail by typing Unsubscribe in the subject line. 
**************************************************************


_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.