Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in running program
#8
Here is complete program now. Thanks for all your help guys here is what I put together.

Code:
'This program is designed to generate passwords. Made by Ali Abdulsater and help from qbasicnews.com forum members.


DEFINT A-Z   'This sets the default data types for variables
RANDOMIZE TIMER   'Randomises the Timer
START: 'Anchor point

DIM characterset AS STRING 'This declares characterset as a STRING
DIM selection AS INTEGER   'This declares selection as a INTEGER


DO 'This is going to be sued to repeat a block of statements

  CLS ' Clear Screen

  PRINT "Password Generator 1.0 by Ali (Hybr!d)"
  PRINT
  PRINT "Charactersets available"
  PRINT
  PRINT "1) Lowercase Alphabet "
  PRINT
  PRINT "2) Uppercase Alphabet "
  PRINT
  PRINT "3) Numbers and Symbols"
  PRINT
  PRINT "4) Lowercase/Uppercase/Numbers and Symbols"
  PRINT
  PRINT "5) Exit Program"
  PRINT
  INPUT "Input your characterset (1/2/3/4) "; selection

             IF selection = 1 THEN

                   characterset = "abcdefghijklmnopqrstuvwxyz"
                   EXIT DO

            ELSEIF selection = 2 THEN

                   characterset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                   EXIT DO

            ELSEIF selection = 3 THEN

                   characterset = "0123456789!?><+_-*&^%$#@,./][\"
                   EXIT DO

            ELSEIF selection = 4 THEN

                   characterset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?><+_-*&^%$#@,./][\"
                   EXIT DO

            ELSEIF selection = 5 THEN
            
                   SYSTEM 'This is used to close all open files and return to Operating system


            ELSE
            
                  PRINT "Invalid Selection"
                  SLEEP 2
                  GOTO START

  END IF

LOOP

DIM Chars AS STRING 'This declares Chars as STRING

Chars = characterset
NChars = LEN(Chars) 'LEN function is used to return number of characters in a string

DO

  CLS

  PRINT "Enter length of password desired (max=36) ";
  INPUT plen
  IF plen > 0 AND plen < 37 THEN 'This checks if the length user input is within range
  
  EXIT DO

  END IF

LOOP

DIM pw AS STRING 'This declares pw as STRING

  randlower = 1
  randupper = NChars

             FOR x = 1 TO plen
  
             rand = INT(RND * randupper) + 1 'Produces random character
      
             pw = pw + MID$(Chars, rand, 1) 'Pickup a char from random position in Chars$
      
             NEXT x 'Goes for next x till user specified length is done
  
  PRINT "The random password is "; pw
  PRINT
  PRINT
PASSWORD: 'Anchor point

DIM save AS STRING 'This declares save as STRING
DIM selection1 AS STRING 'This declares selection1 as STRING


  INPUT "Would you like to save password to file? (y/n)", save
    
  SELECT CASE save 'Used for user to go alternative paths
  CASE "y"

  PRINT
  PRINT
  PRINT "Save in the following manner <filename>.txt"
  PRINT
  PRINT
  INPUT "Save as: ", sf$
  
             OPEN sf$ FOR OUTPUT AS #1
            
             WRITE #1, pw
            
             CLOSE #1
  PRINT
  PRINT "File saved!!"
  PRINT
  
ANOTHERPASS: 'Anchor Point

CLS

  INPUT "Would you like to make another password? (y/n)"; selection1
  
             IF selection1 = "y" THEN
  GOTO START

  ELSEIF selection1 = "n" THEN
  
  SYSTEM

  ELSE
  
  PRINT "Invalid Selection"
  
             SLEEP 1
            
  GOTO ANOTHERPASS
  
  END IF

  CASE "n"
  GOTO START

  CASE ELSE
  
  PRINT "Invalid Selection"
  
  GOTO PASSWORD

END SELECT

SYSTEM
img]http://img213.imageshack.us/img213/6104/sig1jb.gif[/img]
Reply


Messages In This Thread
Error in running program - by Hybr!d - 10-05-2006, 08:42 PM
Error in running program - by Skyler - 10-05-2006, 09:14 PM
Error in running program - by Anonymous - 10-05-2006, 09:29 PM
Error in running program - by Hybr!d - 10-06-2006, 07:23 AM
Error in running program - by Hybr!d - 10-06-2006, 07:39 AM
Error in running program - by Anonymous - 10-06-2006, 01:33 PM
Error in running program - by Hybr!d - 10-06-2006, 02:41 PM
Error in running program - by Hybr!d - 10-06-2006, 03:58 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)