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

Re: Press any key to continue?

"Bamm" <bammster@gmail.com> wrote in message
news:c904823c-2f6b-4128-a107-59cb7cdaa090@s19g2000prg.googlegroups.com...
> There's been so much discussion on my original post, but in the end,
> the answer is simply, it can't be done in Fortran. Thanks for all the
> suggestions though.
It can be done in fortran, if only by binding C:

#include <stdio.h>

int main(void)
{
int ch = '*';
++ ch;

putchar(ch);
putchar('\n');
printf ("Press carriage return\n");
getchar();
}
// gcc -o plus plus.c
This program displays a plus and hangs around because of the getchar call.
I believe that the printf is the only thing that can't be bound here.

system ("pause");
is another one to remember.  Pause is something windows understands, if
that's your game.
--

"I am waiting for them to prove that God is really American."

~~  Lawrence Ferlinghetti



Report this thread to moderator Post Follow-up to this message
Old Post
Gerry Ford
04-01-08 09:49 AM


Re: Press any key to continue?
Gerry Ford wrote:
> "Bamm" <bammster@gmail.com> wrote in message
> news:c904823c-2f6b-4128-a107-59cb7cdaa090@s19g2000prg.googlegroups.com... 
> It can be done in fortran, if only by binding C:
>
> #include <stdio.h>
>
> int main(void)
> {
> int ch = '*';
> ++ ch;
>
> putchar(ch);
> putchar('\n');
> printf ("Press carriage return\n");
> getchar();
> }
> // gcc -o plus plus.c
> This program displays a plus and hangs around because of the getchar call.
> I believe that the printf is the only thing that can't be bound here.
>
> system ("pause");
> is another one to remember.  Pause is something windows understands, if
> that's your game.

You missed the point, as did I at first. He wants the user to be able to
press "any" key, not just the "return" key.

Btw, if "return" key is good enough, you could use the fget intrinsic
supplied by g77, no need for mixing C + fortran.

character c
print *,'Press return key '
i=fget(c)
print *,'Bye'
end


----------------------------------------------------------------------------
----

Report this thread to moderator Post Follow-up to this message
Old Post
user1
04-01-08 01:16 PM


Re: Press any key to continue?

"user1" <user1@example.net> wrote in message news:fst683$o2j$1@aioe.org...
> Gerry Ford wrote: 
>
> You missed the point, as did I at first. He wants the user to be able to
> press "any" key, not just the "return" key.


I feel unusually qualified as furunculus, inventor of the 'any' key.

>
> Btw, if "return" key is good enough, you could use the fget intrinsic
> supplied by g77, no need for mixing C + fortran.
>
>        character c
>        print *,'Press return key '
>        i=fget(c)
>        print *,'Bye'
>        end
>
>
> ------------
--------------
-------------
-------------
--------------
--------------
... thinking about this.


--

"That this social order with its pauperism, famines, prisons, gallows,
armies, and wars is necessary to society; that still greater disaster
would ensue if this organization were destroyed; all this is said only
by those who profit by this organization, while those who suffer from it
- and they are ten times as numerous - think and say quite the contrary."

~~  Leo Tolstoy



Report this thread to moderator Post Follow-up to this message
Old Post
Gerry Ford
04-01-08 01:16 PM


Re: Press any key to continue?
On 2008-04-01 01:11:56 -0300, nospam@see.signature (Richard Maine) said:

> Bamm <bammster@gmail.com> wrote:
> 
>
> Basically, that's right. There can sometimes be system-dependent ways
> that might be acessible from Fortran, but it can't be done directly "in
> Fortran".
>
> Which makes it even more puzzling why such a translation would be
> assigned as part of a homework. Translating something from Basic to
> Fortran (particularly an old version of Fortran) seems like an odd
> homework problem in the first place. It wouldn't fit well in a typival
> Fortran class (because of the assumption that you know Basic). It would
> fit even less well in a typical Basic class. It seems even more odd when
> it is something that can't properly be translated. I suppose it could
> possibly be intended as an illustration of language diferences, but it
> would be a rather "nasty" approach to assign an "impossible" homework
> problem and let you figure out that it is impossible. I've seen profs do
> things like that, but it isn't common.

In an undergraduate course on differetnial equations there was an
exam with a solve 4 of 10 differential equations as one of the problems.
More than 4 were easy and a few were "well known" to be difficult or
worse. The explanation was that part of the training was to know what
you could not do. It was an explanaton that stopped the complaints
about an overly difficult exam. I only learned later that the prof was
a renowned expert on black holes and a student of Schrodinger.

> It leads one to suspect more mundane explanations.

I once had students do the same problem 3 times but with systems of
differing level of abstraction. The purpose was to illustrate the
low level mechanics of the computation as well as the advantages of
high level systems. The problem was to add 10 numbers so it was supposed
to be simple. The course was intended to be about the culture of computing
rather than any particlar language, system, etc.




Report this thread to moderator Post Follow-up to this message
Old Post
Gordon Sande
04-01-08 01:16 PM


Re: Press any key to continue?
user1 <user1@example.net> wrote:

> You missed the point, as did I at first. He wants the user to be able to
> press "any" key, not just the "return" key.
>
> Btw, if "return" key is good enough, you could use the fget intrinsic
> supplied by g77, no need for mixing C + fortran.

If the return key were good enough, there would be no need for anything
so special and system dependent either. A simple, portable, and
standard-conforming

read(*,*)

would be fine.

As noted, that wasn't the OP's question. But I still had trouble letting
such an esoteric answer pass when a much more straightforward one was
available.


--
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain

Report this thread to moderator Post Follow-up to this message
Old Post
Richard Maine
04-02-08 03:39 AM


Re: Press any key to continue?
user1 wrote:

(snip)

> You missed the point, as did I at first. He wants the
> user to be able to press "any" key, not just the "return" key.

Sometimes you don't want "any key".

In the beginning of MS-DOS when formatting disks it would
ask "press any key to continue".  It seems that "any key"
includes control-C.   This stayed at least until
the early use of hard disk drives, and I knew someone
whose hard disk was accidentally reformatted typing
control-C to that prompt.

-- glen


Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
04-02-08 03:39 AM


Re: Press any key to continue?
Richard Maine wrote:
(snip)

> Which makes it even more puzzling why such a translation would be
> assigned as part of a homework. Translating something from Basic to
> Fortran (particularly an old version of Fortran) seems like an odd
> homework problem in the first place. It wouldn't fit well in a typival
> Fortran class (because of the assumption that you know Basic). It would
> fit even less well in a typical Basic class. It seems even more odd when
> it is something that can't properly be translated.

I could imagine it as an introduction to parsing, before a real
class on compiler theory, just to get students thinking about the
problems of language translation.

I did used to have a BNF description for HP BASIC and, before I
had any books or class on compiler theory started to figure out how
I would write a translator.

-- glen



Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
04-02-08 03:39 AM


Re: Press any key to continue?
On Tue, 01 Apr 2008 07:28:03 -0400, user1 <user1@example.net> wrote:

>You missed the point, as did I at first. He wants the user to be able to
>press "any" key, not just the "return" key.
>

Nope. He wants the user to press any key, not "any" key - when you
write it within the parenthesis, you're assuming that there is a key
labeled as such.

:-)

pozdrav
dig

Report this thread to moderator Post Follow-up to this message
Old Post
Luka Djigas
04-02-08 03:39 AM


Re: Press any key to continue?
"Bamm" <bammster@gmail.com> wrote in message
news:d7bf9f1a-a43c-4ed4-88f0-f3a437a160b7@c19g2000prf.googlegroups.com...
> 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.

My CVF compiler supports following...

! -----------------
program test
use dflib
write (*,*) 'wait until a key is pressed'
do
if ( pcharqq() ) exit
end do
write (*,*) 'thank you, i needed that'
end program



Report this thread to moderator Post Follow-up to this message
Old Post
David Frank
04-02-08 03:39 AM


Re: Press any key to continue?
> If the return key were good enough, there would be no need for anything
> so special and system dependent either. A simple, portable, and
> standard-conforming
>
>   read(*,*)
>
> would be fine.
>
> As noted, that wasn't the OP's question. But I still had trouble letting
> such an esoteric answer pass when a much more straightforward one was
> available.

True. And in fact, if you look at my original post, I was in fact
looking for an alternative for read * because read * required an
enter. So we now went a full circle. :)

Report this thread to moderator Post Follow-up to this message
Old Post
Bamm
04-02-08 03:39 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:07 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.