banner



Fortran Press Any Key to Continue

Press any key to continue?

 Press any key to continue?

Author Message

 Press any key to continue?

Sorry if this is a stupid question, but how do you do a "Press any key
to continue"? PAUSE will require you to type "go" while READ *
requires that you press the Enter key.

Wed, 15 Sep 2010 09:33:50 GMT

 Press any key to continue?

Quote:

> Sorry if this is a stupid question, but how do you do a "Press any key
> to continue"? PAUSE will require you to type "go" while READ *
> requires that you press the Enter key.

the answer varies by compiler.  tell us which you use (and off chance
what type of dumb terminal you're using or emulating if any).

--

Gary Scott

fortran Library:  http://www.fortranlib.com

Support the Original G95 Project:  http://www.g95.org
-OR-
Support the GNU GFortran Project:  http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows
it can't be done.

-- Henry Ford

Wed, 15 Sep 2010 10:37:43 GMT

 Press any key to continue?

Quote:

>Sorry if this is a stupid question, but how do you do a "Press any key
>to continue"? PAUSE will require you to type "go" while READ *
>requires that you press the Enter key.

Why not just "Press RETURN to continue" ?

People do seem to have trouble with the "any key" anyway :-)

pozdrav
dig

Wed, 15 Sep 2010 11:02:40 GMT

 Press any key to continue?

Quote:

>>Sorry if this is a stupid question, but how do you do a "Press any key
>>to continue"? PAUSE will require you to type "go" while READ *
>>requires that you press the Enter key.

> Why not just "Press RETURN to continue" ?

> People do seem to have trouble with the "any key" anyway :-)

I always liked 'Q' for "quit".

Quote:

> pozdrav
> dig

--

Gary Scott

Fortran Library:  http://www.fortranlib.com

Support the Original G95 Project:  http://www.g95.org
-OR-
Support the GNU GFortran Project:  http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows
it can't be done.

-- Henry Ford

Wed, 15 Sep 2010 11:08:28 GMT

 Press any key to continue?

Quote:

> >Sorry if this is a stupid question, but how do you do a "Press any key
> >to continue"? PAUSE will require you to type "go" while READ *
> >requires that you press the Enter key.

> Why not just "Press RETURN to continue" ?

Because I'm working on a homework which we are supposed to translate a
program from QBX (Microsoft QuickBasic PDS 7.1) to g77. I couldn't
find a fortran equivalent for the following line:

Do Until Len(Inkey$): Loop

It doesn't have to be a direct equivalent in code, but it should work
the same way. :)

Wed, 15 Sep 2010 11:31:28 GMT

 Press any key to continue?

Quote:

> > >Sorry if this is a stupid question, but how do you do a "Press any key
> > >to continue"? PAUSE will require you to type "go" while READ *
> > >requires that you press the Enter key.

> > Why not just "Press RETURN to continue" ?

> Because I'm working on a homework which we are supposed to translate a
> program from QBX (Microsoft QuickBasic PDS 7.1) to g77. I couldn't
> find a Fortran equivalent for the following line:

> Do Until Len(Inkey$): Loop

> It doesn't have to be a direct equivalent in code, but it should work
> the same way. :)

FORTRAN does not actually even require your computer to have a
keyboard or screen.  To do stuff like changing color, clearing the
screen, or getting a key without waiting for enter, you need to use
curses or conio.  There is curses and conio for Linux and Windows.
You said you are using g77, so you can mix fortran and c. Here's
getting a character without enter in c:

#include <curses.h>

int main() {
int c;

  initscr();

  c = getch();
printf("\r\nGot character: %c.\r\n", c);

  return 0;

Quote:

}

To make a c function that is accessible in fortran, you put an
underscore after it like this:

void initscr_() { initscr(); }
void getch_() { getch(); }

then you can do

PROGRAM WHATEVER
CALL INITSCR
WRITE (*, '(A)' ADVANCE='NO') 'PRESS ANY KEY TO CONTINUE...'
CALL GETCH
END PROGRAM

g77 whatever.f -c
gcc cstuff.c -fno-leading-underscore -c
g77 whatever.o cstuff.o -o whatever

and that should work.

Thu, 16 Sep 2010 09:32:38 GMT

 Press any key to continue?

Quote:

>>> Sorry if this is a stupid question, but how do you do a "Press any key
>>> to continue"? PAUSE will require you to type "go" while READ *
>>> requires that you press the Enter key.
>> Why not just "Press RETURN to continue" ?

> Because I'm working on a homework which we are supposed to translate a
> program from QBX (Microsoft QuickBasic PDS 7.1) to g77. I couldn't
> find a fortran equivalent for the following line:

Interesting exercise. The instructor has you translating from one
obsolete language to another ?

Thu, 16 Sep 2010 21:30:00 GMT

 Press any key to continue?

Quote:

> Interesting exercise. The instructor has you translating from one
> obsolete language to another ?

Yup. You can say that. :)

Thu, 16 Sep 2010 21:58:48 GMT

 Press any key to continue?

Quote:

>>> Sorry if this is a stupid question, but how do you do a "Press any key
>>> to continue"? PAUSE will require you to type "go" while READ *
>>> requires that you press the Enter key.
>> Why not just "Press RETURN to continue" ?

> Because I'm working on a homework which we are supposed to translate a
> program from QBX (Microsoft QuickBasic PDS 7.1) to g77. I couldn't
> find a fortran equivalent for the following line:

> Do Until Len(Inkey$): Loop

> It doesn't have to be a direct equivalent in code, but it should work
> the same way. :)

I think you might be able to use the getchar() function from the C library.

         print *,'Press any key to continue...'
call getchar()
print *, 'Done'
end

You will need to compile with a special option, i.e.
g77 -fno-underscoring whatever.f

Thu, 16 Sep 2010 22:51:13 GMT

 Press any key to continue?

Quote:

> I think you might be able to use the getchar() function from the C library.

>          print *,'Press any key to continue...'
>          call getchar()
>          print *, 'Done'
>          end

> You will need to compile with a special option, i.e.
>      g77 -fno-underscoring whatever.f

I'm sorry it didn't help. It was still asking for an Enter after any
key was pressed. :(

Fri, 17 Sep 2010 09:22:28 GMT

 Press any key to continue?

Quote:

>>I think you might be able to use the getchar() function from the C library.

>>         print *,'Press any key to continue...'
>>         call getchar()
>>         print *, 'Done'
>>         end

>>You will need to compile with a special option, i.e.
>>     g77 -fno-underscoring whatever.f

> I'm sorry it didn't help. It was still asking for an Enter after any
> key was pressed. :(

Is there an equivalent peekchar()?  In some compilers I remember a
function that did not wait for enter.

--

Gary Scott

Fortran Library:  http://www.fortranlib.com

Support the Original G95 Project:  http://www.g95.org
-OR-
Support the GNU GFortran Project:  http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows
it can't be done.

-- Henry Ford

Fri, 17 Sep 2010 09:37:14 GMT

 Press any key to continue?

(snip)

Quote:

> I'm sorry it didn't help. It was still asking for

 >an Enter after any key was pressed. :(

You need something like getch(), which in unix is part
of the ncurses library.  Even with that, you need
cbreak() to turn off line buffering.

This is not part of the Fortran standard, but your
system might have it.

-- glen

Fri, 17 Sep 2010 10:30:03 GMT

 Press any key to continue?

Quote:

>> Sorry if this is a stupid question, but how do you do a "Press any key
>> to continue"? PAUSE will require you to type "go" while READ *
>> requires that you press the Enter key.

> Why not just "Press RETURN to continue" ?

> People do seem to have trouble with the "any key" anyway :-)

My keyboard doesn't even *have* an "Any" key.

cheers,

paulv

p.s. My keyboard also doesn't have a "Return" key.

p.p.s.  :o)

Fri, 17 Sep 2010 22:19:38 GMT

 Press any key to continue?

Quote:

> > Why not just "Press RETURN to continue" ?

> > People do seem to have trouble with the "any key" anyway :-)

> My keyboard doesn't even *have* an "Any" key.

> cheers,

> paulv

> p.s. My keyboard also doesn't have a "Return" key.

> p.p.s.  :o)

I'd just want to add: when I was new using computers, I never had
trouble pressing any key - I thought is was pretty straightforward
English, and I am not a native English speaker!

However I did have trouble finding the RETURN key. I had an ENTER key,
but it took me several weeks to figure out that they were the same.

At least telling a user to press "any" key had double meaning; one may
interpret it the right or wrong way. However there is nothing in
standard English to suggest that the words Return and Enter are
somehow synonymous. One has to have good background in computer
history for this to be naturally understood.

Sat, 18 Sep 2010 00:13:48 GMT

 Press any key to continue?

Quote:

>>> Sorry if this is a stupid question, but how do you do a "Press any key
>>> to continue"? PAUSE will require you to type "go" while READ *
>>> requires that you press the Enter key.

>> Why not just "Press RETURN to continue" ?

>> People do seem to have trouble with the "any key" anyway :-)

> My keyboard doesn't even *have* an "Any" key.

If you go to tacky enough gift shops, you can buy one.  I have a
nice black one with white letters glued to my desktop keyboard. ;)

Dick Hendrickson

p.s.  And yes, it was hard to glue the white letters to the keyboard!

Quote:

> cheers,

> paulv

> p.s. My keyboard also doesn't have a "Return" key.

> p.p.s.  :o)

Sat, 18 Sep 2010 00:14:18 GMT
 [ 30 post ] Go to page: [1] [2] [3]

rosanoveleoper.blogspot.com

Source: http://computer-programming-forum.com/49-fortran/14e327a6c6ec9db8.htm

0 Response to "Fortran Press Any Key to Continue"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel