LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-05-2015, 12:53 PM   #1
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
WHILE WEND For BASH


Not to be confused at all with while do loops, does anyone know of a BASH equivalent of WEND?
 
Old 06-05-2015, 01:30 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
As far as I know while..wend is the syntax for the BASIC while loop. Nothing unique to wend.
 
Old 06-05-2015, 01:49 PM   #3
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by michaelk View Post
As far as I know while..wend is the syntax for the BASIC while loop. Nothing unique to wend.
It is hard to explain, but it could be compared to a "while do" or a "for next" statement, but it is turned inside out. Quite literally a "next for" or a "do while" statement where it loops everything outside of the loop and runs the internal statement when the loop ends and then returns to looping the main program after the interrupt. The practical use of this in basic is to be able to interrupt a loop just long enough to read keyboard input without the need to hit the enter key after the keystroke is entered.
 
Old 06-05-2015, 02:25 PM   #4
brebs
Member
 
Registered: May 2013
Posts: 89

Rep: Reputation: Disabled
lolwut? I think it would be easier if you give an example, rather than try to explain

In BASH:

Code:
while true ; do echo hi ; done
 
Old 06-05-2015, 02:53 PM   #5
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Original Poster
Rep: Reputation: 70
Ok adding to your example it would look something like the following, only this still is not right. It has been decades since I messed with it but a rough example:

Code:
get_key(){
### I forget the exact code in BASH but it gets a single keystroke from the keyboard 
### placing into a variable without the need to use the enter keys.
### Lets just say I am getting "1" and "2" and placing it into x
}
main(){
while ($x == 1); do
echo "1"
done
while ($x == 2); do
echo "2"
done
while ( #It has been too many years but there was some BASIC command that flagged the keyboard interrupt); do
x=$get_key
wend
}
main
In BASIC there was a special function attached to WEND compared to DO that ties into the function of flagging keyboard interrupts. So it was used as an interrupt to a loop without destroying the loop. In more simple terms, real time keyboard input.
 
Old 06-05-2015, 04:07 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Except for Visual Basic I have not used it in years. I'm guessing the special function was unique to the BASIC version you were running.

The built in read command has several options that can be used to simulate the getch() function.
http://www.linuxquestions.org/questi...d-input-34422/

Last edited by michaelk; 06-05-2015 at 06:52 PM.
 
1 members found this post helpful.
Old 06-05-2015, 04:11 PM   #7
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by michaelk View Post
Expect for Visual Basic I have not used it in years. I'm guessing the special function was unique to the BASIC version you were running.

The built in read command has several options that can be used to simulate the getch() function.
http://www.linuxquestions.org/questi...d-input-34422/
That looks promising! Lots of reading to do ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[To share Bash knowledge]Notes for Advanced Bash-Scripting Version 10 (Latest) jcky Programming 4 07-31-2014 09:24 AM
[SOLVED] Bash Script - Reading User Input while Processing output from Command within Bash cleeky Linux - General 5 05-27-2014 02:57 PM
Bash problem : -bash: [: /bin/bash: unary operator expected J.A.X Linux - Software 1 09-22-2011 05:52 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration