Quote:

> Can anybody help me find a way to get every possible

> combination of capital and lower case letters for a string.

> Here's what I have so far.

> OPEN "A.TXT" FOR OUTPUT AS #1

> A$ = "abcdef"

> FOR i% = 1 TO LEN(A$)

> A1$ = A$

> MID$(A1$, i%, 1) = UCASE$(MID$(A1$, i%, 1))

> PRINT #1, A1$

> FOR j% = i% + 1 TO LEN(A1$)

> A2$ = A1$

> MID$(A2$, j%, 1) = UCASE$(MID$(A2$, j%, 1))

> PRINT #1, A2$

> FOR K% = j% + 1 TO LEN(A1$)

> A3$ = A2$

> MID$(A3$, K%, 1) = UCASE$(MID$(A3$, K%, 1))

> PRINT #1, A3$

> NEXT K%

> NEXT j%

> NEXT i%

> Of course I would need to nest another 3 loops in there to go

> completely through every combination, but I'm trying to find a

> way to do it that isn't dependent on the length of the string.

-----------------------------------------------------------------

It appears you're using uppercase letters to "mark" those letters

selected to be part of a combination. If this is correct, your

stated goal of "every possible combination of capital and lower

case letters for a string" is at at odds with your code's output.

Combinations can be generated recursively as in:

DECLARE SUB Comb (C$, l%, cs%, f%)

DEFINT A-Z

CONST E$ = "abcdef"

CLS : n = LEN(E$)

for r:=1 to 3: C$ = "": CALL Comb((C$), n, r, 1): next r

SUB Comb (C$, l, cs, f)

IF cs = 0 THEN

PRINT C$

ELSE

FOR i = f TO l - cs + 1

CALL Comb(C$ + MID$(E$, i, 1), l, cs - 1, i + 1)

NEXT i

END IF

END SUB

If you really wanted to treat upper and lower case letters as

unique objects, change the value of E$ to include both cases as

in CONST E$ = "abcdefABCDEF".

-----------------------------------------------------------------

Derek Asari