Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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.

Report this thread to moderator Post Follow-up to this message
Old Post
Bamm
03-29-08 03:17 AM


Re: Press any key to continue?
Bamm wrote:

> 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
mailto:garylscott@sbcglobal dot net

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

Report this thread to moderator Post Follow-up to this message
Old Post
Gary Scott
03-29-08 03:17 AM


Re: Press any key to continue?
On Fri, 28 Mar 2008 18:33:50 -0700 (PDT), Bamm <bammster@gmail.com>
wrote:

>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

Report this thread to moderator Post Follow-up to this message
Old Post
Luka Djigas
03-29-08 03:17 AM


Re: Press any key to continue?
Luka Djigas wrote:

> On Fri, 28 Mar 2008 18:33:50 -0700 (PDT), Bamm <bammster@gmail.com>
> wrote:
>
> 
>
>
> Why not just "Press RETURN to continue" ?
>
> People do seem to have trouble with the "any key" anyway :-)

I always liked 'Q' for "quit".

>
> pozdrav
> dig


--

Gary Scott
mailto:garylscott@sbcglobal dot net

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

Report this thread to moderator Post Follow-up to this message
Old Post
Gary Scott
03-29-08 03:17 AM


Re: Press any key to continue?
> >Sorry if this is a stupid question, but how do you do a "Press any 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. :)

Report this thread to moderator Post Follow-up to this message
Old Post
Bamm
03-29-08 09:41 AM


Re: Press any key 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;
}

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.



Report this thread to moderator Post Follow-up to this message
Old Post
dean.menezes@gmail.com
03-30-08 03:35 AM


Re: Press any key to continue?
Bamm wrote: 
>
> 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 ?




Report this thread to moderator Post Follow-up to this message
Old Post
user1
03-31-08 02:14 AM


Re: Press any key to continue?
> Interesting exercise. The instructor has you translating from one
> obsolete language to another ?

Yup. You can say that. :)

Report this thread to moderator Post Follow-up to this message
Old Post
Bamm
03-31-08 02:15 AM


Re: Press any key to continue?
Bamm wrote: 
>
> 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

Report this thread to moderator Post Follow-up to this message
Old Post
user1
03-31-08 02:16 AM


Re: Press any key to continue?
> 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. :(

Report this thread to moderator Post Follow-up to this message
Old Post
Bamm
03-31-08 02:19 AM


Sponsored Links




Last Thread Next Thread Next
Pages (3): [1] 2 3 »
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.