Here's another....file I/O difficulties. - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html) +--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html) +--- Thread: Here's another....file I/O difficulties. (/thread-8714.html) |
Here's another....file I/O difficulties. - Zack - 01-09-2006 I can't figure this out. I'm trying to make a very simple Encryption/decryption console app. The first error is on the OPEN Filename FOR BINARY AS #F. It says there's a type mismatch at parameter 1. Now, I'm not sure why. I assume parameter 1 is Filename. And I've dimensioned that as a STRING already. Why the type mismatch? Now, I replace that with hard text, like "c:\foo.txt" and that solves that error...for some reason. Then there's another. On the "IF KeyString="" THEN..." part, it lists another type mismatch. "Type mismatch, found THEN". I can't seem to work around that one. Any ideas folks? Code: OPTION EXPLICIT Here's another....file I/O difficulties. - stylin - 01-09-2006 Code: DIM Filename,KeyString,RealText,CipherText AS STRING Code: DIM as string Filename, KeyString, RealText, CipherText This is another reason why 1. You should avoid multiple declarations (DIMs) on one line. 2. Declare variables only when you immediately need them, ie., not all at once at the top of the program. Post again if you have any more troubles. Here's another....file I/O difficulties. - Zack - 01-09-2006 Thanks, man! I didn't know that. I kneaded out a few other problems on my own. Here's the finished code: Code: OPTION EXPLICIT Not a very strong encryption, but alright if you want to stop your little brother from changing your settings in photoshop. :wink: There is one thing more. Why doesn't the ERR handling thing work? If I enter a wrong filename, it doesn't tell me so, as it should. Here's another....file I/O difficulties. - stylin - 01-09-2006 Code: IF ERR THEN=2 I'm not sure how this even compiles. Does it? Try this: Code: IF ERR=2 THEN Here's another....file I/O difficulties. - Zack - 01-10-2006 Sorry, copying error, I accidentaly changed it. Your correction is right. Thanks. Here's another....file I/O difficulties. - stylin - 01-10-2006 Not a problem. Here's another....file I/O difficulties. - Moneo - 01-10-2006 Quote:.....I you want a simple but more robust encryption algorithm, try the following by Ethan Winer. It's even less code than yours. Code: rem X$ is the string to be encrypted. Here's another....file I/O difficulties. - Zack - 01-10-2006 Well, I don't know how it works but it does seem solid. Neat. Here's another....file I/O difficulties. - Moneo - 01-10-2006 Don't feel bad, Zack, I don't really understand it either. This code is right out of Ethan Winer's book available free at: www.ethanwiner.com Back in 1990, for an encryption utility, I used the original assembly language version which was in Winer's QuickPak Professional Library, and it has always worked fine. ***** Here's another....file I/O difficulties. - stylin - 01-10-2006 Quote:Well, I don't know how it works but it does seem solid. Neat.Simply, it overlays Password$ end-to-end over X$, then XORs X$ based on the value of Password$ at that character: Code: This is the line to be encrypted. Code: This is the line to be encrypted. |