* *

Coding

Welcome, Guest. Please login or register.
Did you miss your activation email?
November 19, 2017, 01:55:23 AM

Login with username, password and session length

Menu

Members
Stats
  • Total Posts: 12175
  • Total Topics: 1736
  • Online Today: 34
  • Online Ever: 195
  • (February 11, 2014, 01:46:08 PM)
Users Online
Users: 0
Guests: 34
Total: 46
Yahoo!
Baidu (11)

Author Topic: Press any key to continue  (Read 2799 times)

0 Members and 1 Guest are viewing this topic.

Offline Columbo

  • Newbie
  • *
  • Posts: 6
  • Bananas: 0
  • Gender: Male
  • I haven't set any personal text yet
    • Canadian Amateur Radio
Press any key to continue
« on: August 26, 2014, 07:01:58 PM »
Before getting into any windows programming I thought I would try a couple of short console programs first. I did a simple program to calculate the length of a dipole antenna.

Here is the code:

Code: [Select]
'Test Console program

OPENCONSOLE

CLS

DEF freq as float
DEF result as float
DEF leg as float

INPUT "Enter your frequency:  ",freq

result = 468/freq
leg = result/2

CLS
PRINT
PRINT "Your antenna is: " + Str$(result) + " feet long."
PRINT
PRINT "Each leg is " + Str$(leg) + " feet long."
PRINT
PRINT "Please press any key to close!"

DO: UNTIL INKEY$ <> ""

CLOSECONSOLE

END


It works but after it displays "Please press any key to close" and you press a key,  it then displays "Press any key to continue..." so you have to press a key a second time.

Then to experiment a bit, I REMed out the two lines PRINT "Please press any key to close!" and the DO: UNTIL INKEY$ <> "".

Code now looks like this:

Code: [Select]
'Test Console program

OPENCONSOLE

CLS

DEF freq as float
DEF result as float
DEF leg as float

INPUT "Enter your frequency:  ",freq

result = 468/freq
leg = result/2

CLS
PRINT
PRINT "Your antenna is: " + Str$(result) + " feet long."
PRINT
PRINT "Each leg is " + Str$(leg) + " feet long."
PRINT
 
/*
*PRINT "Please press any key to close!"

*DO: UNTIL INKEY$ <> ""
*/

CLOSECONSOLE

END


Now I get "Press any key to continue..." and when I press a key the program ends, as it should.  My question is, with those two lines REMed out, why am I getting the "Press any key to continue..." ?
Webmaster: Code In Basic - http://www.codeinbasic.com

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Press any key to continue
« Reply #1 on: August 26, 2014, 09:59:22 PM »
You can compile a "console" program as a CONSOLE type or as a WINDOWS type application in IWBasic.

If you compile it as a CONSOLE type then IWBasic supplies the "Please press any key to continue . . ." message.
There fore you don't need the
Code: [Select]
DO: UNTIL INKEY$ <> "".Also

If you compile it as a WINDOWS type then IWBasic does not supply the "Please press any key to continue . . ." message.
There fore you do need the
Code: [Select]
DO: UNTIL INKEY$ <> "".
What you are seeing is a subtle difference between version 1.737 of EBasic and 2.x version of IWBasic.

Also, when compiling as a CONSOLE type there is no need for the OPENCONSOLE and CLOSECONSOLE commands.

This was addressed in April 2012 on the IonicWind forums here http://www.ionicwind.com/forums/index.php?topic=4941.msg37696#msg37696
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

Offline Columbo

  • Newbie
  • *
  • Posts: 6
  • Bananas: 0
  • Gender: Male
  • I haven't set any personal text yet
    • Canadian Amateur Radio
Re: Press any key to continue
« Reply #2 on: August 27, 2014, 12:12:23 AM »
Ok, but what part of the program is actually invoking the "Press any key to continue..."?  What if you don't want the program to pause at that point and wanted it to go on to do something else other than PRINT the result to the screen? Is it somehow invoked because you used an INPUT statement?

I'm just trying to understand how this is working.

By the way, how many posts are required in order to no longer have to answer the 5 security questions when posting?
« Last Edit: August 27, 2014, 12:20:16 AM by Columbo »
Webmaster: Code In Basic - http://www.codeinbasic.com

Offline Larry McCaughn

  • Head Monkey
  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Bananas: 4
  • Gender: Male
Re: Press any key to continue
« Reply #3 on: August 27, 2014, 12:38:07 AM »
Ok, but what part of the program is actually invoking the "Press any key to continue..."?  What if you don't want the program to pause at that point and wanted it to go on to do something else other than PRINT the result to the screen? Is it somehow invoked because you used an INPUT statement?
It's a combination of two things.  One is the END command which is saying "Hey, I'm done." And the other aspect is that the program is compiled as a CONSOLE app.
If you want it to do something else other than PRINT write the code to do it and when you've done everything you want to do issue the END command. If you want it to run and then close with no pause or user input then compile it as a WINDOWS app as stated in the referenced post @ IonicWind..  The use of the INPUT statement has absolutely nothing to do with it.

By the way, how many posts are required in order to no longer have to answer the 5 security questions when posting?
5; you'd be surprised how many people register just so they can post spam of some sort with automatic programs.
The programs try a couple of times and then quit trying.
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x/3.x)

Offline Columbo

  • Newbie
  • *
  • Posts: 6
  • Bananas: 0
  • Gender: Male
  • I haven't set any personal text yet
    • Canadian Amateur Radio
Re: Press any key to continue
« Reply #4 on: August 27, 2014, 03:40:42 AM »
I didn't think that the INPUT statement should have anything to do with it but I never ran across this automatic "Please press any key to continue . . ." in my old DOS basic.  :)

And, yes, I understand the spam problem.  I have had similar problems with my Amateur Radio forum running on vBulletin.

Cheers
Webmaster: Code In Basic - http://www.codeinbasic.com

 

To link to us use this code/button on your site

http://www.codingmonkeys.com/images/cm_link.gif

ShoutBox!

 

lurkalot

September 20, 2017, 01:57:54 PM
Hey that's my job. Didn't choose this username for nothing you know.  :)
 

Larry McCaughn

September 19, 2017, 12:24:13 AM
lurking in the shadows, lurkalot.
 

lurkalot

September 16, 2017, 04:39:43 PM
Good evening all.  Where is everyone?
 

lurkalot

September 12, 2017, 12:57:36 PM
Good to hear, it's nice to see a empty error log. ;)
 

Blue Steel

September 12, 2017, 05:04:25 AM
running sites log files overnight heres the result (I know mainly spiners) "There are currently no error log entries." :)
 

lurkalot

September 12, 2017, 03:19:33 AM
Morning all.  :)
 

Blue Steel

September 12, 2017, 01:12:33 AM
Let it all out ..
these are the things I can't do without  ;)

MikeHart

September 11, 2017, 11:14:22 PM
SHOUT SHOUT  :)
 

GWS

September 11, 2017, 08:16:02 PM
Shouting is Go !  ;D
 

Blue Steel

September 11, 2017, 06:54:02 PM
gradually getting there
 

lurkalot

September 11, 2017, 05:22:46 PM
Yay, you found it.  ;)
 

Larry McCaughn

September 11, 2017, 01:07:13 PM
looks like you're making good progress
 

Blue Steel

September 07, 2017, 10:34:19 PM
yay recent topics are working again in the center of the home page :)
 

Larry McCaughn

July 12, 2017, 05:46:33 PM
Blue Steel is back running the show.  Maybe he'll be able to build some steam in the ole place!
 

Blue Steel

June 26, 2017, 04:58:41 AM
hope i didn't scare too many of you
 

Blue Steel

June 26, 2017, 04:58:12 AM
Boo, i'm still here alive and well , see my post in introductions

MikeHart

July 25, 2016, 01:43:24 AM
That sounds cool. Have to chekc out IWBasic in the next days.
 

Larry McCaughn

July 22, 2016, 11:47:00 PM
I'm hoping to issue a new maintenance release to the IWBasic 3.x IDE in the next few weeks and Larry Sikes has released an update to the Linux version of IWBasic and is currently working on the 64bit version of IWBasic.  Progress should speed up since he has retired and has apparently resolved his m

MikeHart

July 19, 2016, 02:53:02 PM
Anything interesting going on around BASIC?
 

Larry McCaughn

July 18, 2016, 09:14:12 AM
Hello Mike

MikeHart

July 16, 2016, 04:33:25 PM
Hi there all!
 

pistol350

June 24, 2016, 03:41:10 AM
Hello all!
I'm still around although less active!
 

Blue Steel

September 08, 2013, 09:34:55 AM
first page of games in arcade are fixed. only 12 more pages to go
 

Blue Steel

September 08, 2013, 08:41:09 AM
Cleared all highscores on the games . i've been asked to see if i can fix them all. please PM me if you find a game in the arcade that doesn't work, there are way too many for me to go through each and every game.