Computer Science Canada File Manipulation - Code |
Author: | homer [ Wed Dec 01, 2004 9:56 pm ] |
Post subject: | File Manipulation - Code |
Hey I'm trying to accomplish the following Create File: -Create File using randomly generated dots write to file -insert "|" to seperate dots, and ">" to go to next line. Read -Read file and display image using file data Encrypt/Compress File: I'm not sure what this would technically be called I think it is closer to encryption. -look for the most frequently occuring colors Example file: 201|89|89|189|20|99> 201|99|18|181|20|99> Search for largest string, and decend to the smallest re-occuring string 201|=! 89|=@ 20=# 99=$ 18=^ ..etc !|@@1@#|$> !|$^|^1|#|$> var fileName : string := "apple.gmp" var fileNo : int var inputVariable : string (100) var streamnumber : int var count : int := 0 var trow : int := 1 open : streamnumber, fileName, put, mod, seek for x : 1 .. 5 for y : 1 .. 5 var c : int := Rand.Int (1, maxcolor) drawdot (x, y, c) count += 1 if count = 5 then put : streamnumber, c, ">" .. count := 0 else put : streamnumber, c, "|" .. end if end for end for seek : streamnumber, * put : streamnumber, "GMP" close : streamnumber open : fileNo, fileName, read read : fileNo, inputVariable locate (trow, 1) put inputVariable char close : fileNo |
Author: | SuperGenius [ Thu Dec 02, 2004 7:29 pm ] |
Post subject: | |
take a look through the tutorials section. Read up on external files. As for the encryption/compression, I don't really know what that's about. You could use a shift cipher, or if you want to get really fancy you could make a one-time cipher program, which is the most secure encryption, although it would take a lot more work. |