Code Comments
Programming Forum and web based access to our favorite programming groups.
"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
Post Follow-up to this messageGerry 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
----------------------------------------------------------------------------
----
Post Follow-up to this message"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
Post Follow-up to this messageOn 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.
Post Follow-up to this messageuser1 <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
Post Follow-up to this messageuser1 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
Post Follow-up to this messageRichard 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
Post Follow-up to this messageOn 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
Post Follow-up to this message"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
Post Follow-up to this message> 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. :)
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.