Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Outputting to file
#1
For some reason, my program prints just one line, then quits. I'm thinking it may be because my encryption program is sticking an EOF character in on accident, but not sure...

Code:
Dim plaintxt As String
Dim filename As String
Dim pass As Integer
Dim xorchar As Integer
Dim encrypted As String
Dim ciphered As String
Dim outfile As String
Dim file1 As Integer
Dim file2 As Integer

Input "File to encrypt: ", filename
Input "Password (numeric): ", pass
Input "File to output to: ", outfile
file1 = FreeFile
Open filename For Input As #file1
file2 = FreeFile
Open outfile For Output As #file2

Randomize pass

While Not EOF(file1)
    Line Input #file1, plaintxt
    
    For i = 1 To Len(plaintxt)
        xorchar = Int(Rnd(1) * 255 + 1)
        encrypted += chr$(asc(mid$(plaintxt,i,1)) xor xorchar)
    Next i
    Print #file2, encrypted
Wend
Close #1
Close #2
Print "Done!"
Print
Print

'Try unencrypting

Input "File to cipher: ", filename
Input "Password (numeric): ", pass
Input "Output File: ", outfile

file1 = FreeFile
Open filename For Input As #file1
file2 = FreeFile
Open outfile For Output As #file2
Randomize pass

While Not Eof(file1)
    Line Input #file1, encrypted
    For i = 1 To Len(encrypted)
        xorchar = Int(Rnd(1) * 255 + 1)
        ciphered += chr$(asc(mid$(encrypted, i, 1)) xor xorchar)
    Next i
    Print #file2, ciphered
Wend
Close #1
Close #2

Print "Done!"
sleep

Any ideas how to fix it?
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply


Messages In This Thread
Problem with Outputting to file - by Torahteen - 06-18-2006, 09:31 PM
Problem with Outputting to file - by WaffleMan - 06-19-2006, 03:26 AM
Problem with Outputting to file - by Torahteen - 06-20-2006, 06:04 AM
Problem with Outputting to file - by axipher - 06-20-2006, 06:46 AM
Problem with Outputting to file - by yetifoot - 06-20-2006, 09:56 AM
Problem with Outputting to file - by Torahteen - 06-20-2006, 08:11 PM
Problem with Outputting to file - by Anonymous - 06-20-2006, 11:55 PM
Problem with Outputting to file - by yetifoot - 06-21-2006, 01:54 AM
Problem with Outputting to file - by DrV - 06-21-2006, 06:04 PM
Problem with Outputting to file - by Torahteen - 06-21-2006, 07:46 PM
Problem with Outputting to file - by Zack - 06-21-2006, 10:55 PM
Problem with Outputting to file - by Anonymous - 06-22-2006, 01:43 AM
Problem with Outputting to file - by yetifoot - 06-22-2006, 03:01 AM
Problem with Outputting to file - by Torahteen - 06-22-2006, 08:31 PM
Problem with Outputting to file - by Zack - 06-22-2006, 08:55 PM
Problem with Outputting to file - by Anonymous - 06-23-2006, 05:14 AM
Problem with Outputting to file - by yetifoot - 06-23-2006, 06:53 AM
Problem with Outputting to file - by Anonymous - 06-23-2006, 08:24 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)