For Programmers: Free Programming Magazines  


Home > Archive > Fortran > May 2005 > any modern counterpart of "if sense switch"?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author any modern counterpart of "if sense switch"?
Charles Russell

2005-05-21, 3:56 pm

Is there any modern counterpart of the old fortran IV "if sense switch"
command that will let me send a signal from the keyboard without killing
the process? I'm using cygwin/g77 or cygwin/gfortran.
Jim

2005-05-21, 3:56 pm


"Charles Russell" <SPAMworFREEwor@bellsouth.net> wrote in message
news:i1Jje.3470$lQ3.944@bignews5.bellsouth.net...
> Is there any modern counterpart of the old fortran IV "if sense switch"
> command that will let me send a signal from the keyboard without killing
> the process? I'm using cygwin/g77 or cygwin/gfortran.

Wasn't that statement actually part of the original Fortran? Anyway, it is
long gone. I don't remember it being in Fortran IV.
Jim


Charles Russell

2005-05-21, 3:56 pm

Jim wrote:
> "Charles Russell" <SPAMworFREEwor@bellsouth.net> wrote in message
> news:i1Jje.3470$lQ3.944@bignews5.bellsouth.net...
>
>
> Wasn't that statement actually part of the original Fortran? Anyway, it is
> long gone. I don't remember it being in Fortran IV.
> Jim
>
>

Well, maybe that was in IBM 1620 fortran. Anyway, it would be helpful
to me to find some modern equivalent. g77 implements the C "signal"
facility, but I have no idea how to raise a signal other than ^C from
the PC keyboard.
Dick Hendrickson

2005-05-21, 3:56 pm



Charles Russell wrote:

> Is there any modern counterpart of the old fortran IV "if sense switch"
> command that will let me send a signal from the keyboard without killing
> the process? I'm using cygwin/g77 or cygwin/gfortran.


On thing that will work is to use INQUIRE to see if a
particular file exists. Use the keyboard to create or
delete a file and test it dynamically within the
program. You can also use OPEN to send signals
from the program to the keyboard.

Whether or not that's "modern" is a judgment call; but it
doesn let you use something a little more mnemonic that
"3" for the testee.

Dick Hendrickson

Charles Russell

2005-05-21, 3:56 pm

Dick Hendrickson wrote:
>
>
> Charles Russell wrote:
>
>
>
> On thing that will work is to use INQUIRE to see if a
> particular file exists. Use the keyboard to create or
> delete a file and test it dynamically within the
> program.


Yes, this solves my problem. Thanks.

You can also use OPEN to send signals
> from the program to the keyboard.


This I don't understand. Could you give an example of an OPEN statement
that does something with the keyboard? And what would the keyboard do
with a signal?

> Whether or not that's "modern" is a judgment call; but it
> doesn let you use something a little more mnemonic that
> "3" for the testee.


A typo, you presumably meant "does let you". Thus: touch now_do_X

Dick Hendrickson

2005-05-21, 3:56 pm



Charles Russell wrote:

> Dick Hendrickson wrote:
>
>
>
> Yes, this solves my problem. Thanks.
>
> You can also use OPEN to send signals
>
>
>
> This I don't understand. Could you give an example of an OPEN statement
> that does something with the keyboard? And what would the keyboard do
> with a signal?

Poor wording. I meant send a "signal" that can be detected
by the user at the keyboard. Typing "ls" or "dir" or
whatever repeatedly will let you "sense" when the program
has created a file. You could do the same thing with
Print *, "I am here", but file creation can also be
sensed by other programs with an INQUIRE, allowing
process to process communication.
>
>
>
> A typo, you presumably meant "does let you". Thus: touch now_do_X

Yes, more like an eraseo, I changed the sense of the
statement and didn't completely backtrack.

Dick Hendrickson
>


mcalhoun@ksu.edu

2005-05-21, 8:57 pm

Charles Russell <SPAMworFREEwor@bellsouth.net> writes:
>Is there any modern counterpart of the old fortran IV "if sense switch"
>command that will let me send a signal from the keyboard without killing
>the process? I'm using cygwin/g77 or cygwin/gfortran.


Not particularly portable, but many systems may provide a routine that
will check the keyboard without waiting for a key. For instance, I do
99% of my programming on a PC, and here is the "documentation" for two
such routines (from a freeby package called "ELMOP"):

IGTKYE (Get a key if one is ready (do NOT wait), echo it on the screen)
IGTKEY (Get a key if one is ready (do NOT wait), do not echo it)

CHARACTER KeyA*2
INTEGER*2 KeyI(2), Flag, igtkey, igtkye

Flag = IGTKYE ( KeyI, KeyA )
Flag = IGTKEY ( KeyI, KeyA )

where ---
IGTKEY = INTEGER*2 function returns key found flag
(0=key not ready, nothing returned
1=key ready and returned in KeyI and KeyA)
IGTKYE = INTEGER*2 function returns key found flag
(0=key not ready, nothing returned
1=key ready, returned in KeyI and KeyA and echoed)
KeyI = Integer value of key according to ASCII table
KeyI(1)=key and KeyI(2)=0 for ASCII
KeyI(1)=0 and KeyI(2)=code for Extended keys
i.e. Function keys & Keypad keys
KeyA = Character value of key according to ASCII
KeyA(1:1)=key and KeyA(2:2)=nul for ASCII
KeyA(1:1)=nul and KeyA(2:2)=code for Extended keys
i.e. Function keys & Keypad keys

--Myron.
--
--Myron A. Calhoun.
Five boxes preserve our freedoms: soap, ballot, witness, jury, and cartridge
PhD EE (retired). "Barbershop" tenor. CDL(PTXS). W0PBV. (785) 539-4448
NRA Life Member and Certified Instructor (Home Firearm Safety, Rifle, Pistol)
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com