LinuxQuestions.org
Visit Jeremy's Blog.
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 08-31-2007, 06:05 AM   #1
scbops
Member
 
Registered: Feb 2006
Posts: 97

Rep: Reputation: 15
making a loop


How can I write a loop which runs in a sequence of “a-z”, “A-Z” and “0-9”
 
Old 08-31-2007, 07:22 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
what language are you using?
 
Old 08-31-2007, 08:08 AM   #3
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Since you did not mention what language you are using(which is not important right?), I suppose it is visual basic. You could have a static array with all the letters and numbers like this:

Quote:
Dim strLetters(6) As String

strLetters(0) = "A"

strLetters(1) = "B"

strLetters(2) = "C"

strLetters(3) = "D"

strLetters(4) = "E"

strLetters(5) = "F"

strLetters(6) = "G"
then, when you need to acess any of the data from the array, loop then like this:

Quote:
Dim letter As Integer

For letter = 0 To 6

Form1.Print strLetters(letter)

Next letter
That should do it...
 
Old 08-31-2007, 09:11 AM   #4
scbops
Member
 
Registered: Feb 2006
Posts: 97

Original Poster
Rep: Reputation: 15
am using the bash shell scripts
 
Old 08-31-2007, 09:27 AM   #5
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Would this do?
Code:
i=32; while [ $i -lt 256 ]; do eval echo "\$'\\$i'"; i=$(($i + 1)); done | grep -x '[A-Za-z0-9]'
Yves.
 
Old 08-31-2007, 11:00 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
i'm intrigued to know what train of thought makes vb the default language!
 
Old 08-31-2007, 04:21 PM   #7
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Its mega man who knows.......



Here is how you could do it in C tho there are alot of diffrent ways it could be done.

Code:
 
#include<stdio.h> 

int main ()
{ 
     int letter; 



     letter = 'A'; 

      
     for(;letter <= 'Z';) 
        { 
              printf("%c\n",letter);     
              letter++; 
        } 
 return 0; 
}

Last edited by exvor; 08-31-2007 at 04:32 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 9 07-28-2015 03:49 PM
bash loop within a loop for mysql ops br8kwall Programming 10 04-30-2008 03:50 AM
If, else, then or loop, help. ncsuapex Programming 10 02-24-2006 03:07 PM
for loop only works properly on first loop symo0009 Programming 1 12-25-2005 05:17 PM
help with the following C loop ..... purpleburple Programming 12 08-06-2002 10:32 PM

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

All times are GMT -5. The time now is 04:34 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