Download text file
#IF 0
    ----------------------------                      PowerBASIC v7.x
 ---|          DASoft          |------------------------------------------
    ----------------------------         Code           DATE: 2004-12-02
    | FILE NAME PwrdMaker.bas  |          by
    ----------------------------  Don Schullian, Jr.

              This code is released into the Public Domain
       ----------------------------------------------------------
        No guarantee as to the viability, accuracy, or safety of
         use of this code is implied, warranted, or guaranteed
       ----------------------------------------------------------
                         Use at your own risk!
       ----------------------------------------------------------
                 CONTACT AUTHOR AT basic@DASoftVSS.com
 -------------------------------------------------------------------------

I needed this little function for a program I'm working on so I thought I'd
post it for whoever wants it.

If you don't set any value for $PasswordInclude then it is ignored completely.

#ENDIF

$PasswordInclude = "012345789!#$%^&"

FUNCTION fPasswordMaker ALIAS "fPasswordMaker" ( BYVAL MinLtrs AS LONG, _
                                                 BYVAL MaxLtrs AS LONG  ) EXPORT AS STRING

  DIM C        AS LOCAL LONG
  DIM L        AS LOCAL LONG
  DIM Password AS LOCAL STRING

  L        = RND(MinLtrs,MaxLtrs)
  Password = SPACE$(L)

  DO
    SELECT CASE RND(1,20)
      CASE 1 TO 5  : C = RND(48,57)
      CASE 6 TO 13 : C = RND(97,122)
      CASE ELSE    : C = RND(65,90)
    END SELECT
    ASC(Password,L) = C
    DECR L
  LOOP UNTIL L = 0

$if %DEF($PasswordInclude)
  IF INSTR(Password,ANY $PasswordInclude) THEN
    L = RND(1,L)
    ASC(Password,L) = ASC($PasswordInclude,RND(1,LEN($PasswordInclude)))
  END IF
#endif

  FUNCTION = RTRIM$(Password)

END FUNCTION
'
'------------------------------------------------------------------------------
'
FUNCTION PBmain ()

  DIM Txt AS LOCAL STRING
  DIM X   AS LOCAL LONG

  RANDOMIZE TIMER
  FOR X = 1 TO 10
#if %DEF(%PB_CC32)
   PRINT fPasswordMaker(5,12)
#else
   Txt = Txt & fPasswordMaker(5,12) & $CRLF
#endif
  NEXT

#if %DEF(%PB_CC32)
   WAITKEY$
#else
   MSGBOX Txt
#endif

END FUNCTION