Page 1 of 1

Encoding files?

PostPosted: Tue Dec 06, 2011 12:28 am
by SuperSonic
Hey everyone. I was wondering how I can encode a file using GE script. To be more specific, I want a bit of code that will open a file and then read each character. For each character it reads, it will add a certain number to it's ID and store the result in an array. So for example, it would take the string "abc" and turn it into "def". See what I mean? :D

I promise to give points to anyone who can solve the problem. Thank you :P

Sonic

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 2:43 am
by tintran
file "abc.c" contains
abc
last line of file here.

output
def odvw#olqh#ri#iloh#khuh1

is that right?
Edit: removed .zip with missing data folder.

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 3:25 am
by SuperSonic
Thanks but could you upload the data folder with the ttf? :D

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 4:10 am
by tintran
whoops,
here it is

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 1:44 pm
by SuperSonic
Thanks. I'll check it out :D

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 2:04 pm
by SuperSonic
Great, it works just fine. +1 :wink:

However, I'm a complete newb when it comes to file Input/Output so could you answer a few questions for me? :roll:
So even though the code works, I have no clue what all of the functions mean. Could you explain them to me?
If I wanted to overwrite the abc.c file, what code should I use?
I will have to decode the file as well so what code should I use for that?

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 6:32 pm
by SuperSonic
I wrote:If I wanted to overwrite the abc.c file, what code should I use?

Actually, I think I figured that part out myself but could you still answer the other two questions I had? :)

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 7:36 pm
by tintran
here's some additional code for writing to file
and an extra function called codeString (which encodes and decodes depending on the id you pass it)
each line of code is commented

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 7:58 pm
by SuperSonic
Thanks dude. This is perfect :D

Another +1 :wink:

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 8:13 pm
by tintran
i have 10 points , yes! :D

Re: Encoding files?

PostPosted: Tue Dec 06, 2011 8:31 pm
by SuperSonic
tintran wrote:i have 10 points , yes! :D

:P