Blitz (7/144)

From:Sami Näätänen
Date:6 May 2001 at 11:10:00
Subject:Re: File Creating&Reading

Mac MacMende wrote:
>
> Hi Everybody!
>
> Yes, I got another problem...now that I got the Intro nearly ready (thanx
> again), I started to crypt the Highscores. For this, I wrote a small
> programm, that converts Normal Text into mystical top-secret code (*g*) and
> saves it.
>
> Then I got another Programm which decrypts this mystical
> top-secret-Highscore-Code and prints it in a window.
>
> Well, but the second programm can't read the file the first program has
> created. Don't know why...
> But the second programm can read normal docs written with ED.
>
> The code of the programms:
>
> 1. (shorted)
>
> If OpenFile(0,"text")
> a$="HALLO"
> FileOutput 0
> Print a$
> CloseFile 0
> Endif
>
> 2. (also shorted)
>
> If ReadFile(0,"text")
> FileInput 0
> a$=Edit$(Lof(0))
> Print a$
> CloseFile 0
> Endif
>
> Anyone got an Idea why this doesn't work?
>

What are you printing to the file, because it have to be normal ASCII
text or else you can't read it in with edit$ and be sure that it works.
So does the reading proggy read partial file or what. Have you looked
the output of your first proggy with text editor so that it contains
visible characters and that the first character of the file is NOT LF.
because edit$ doesn't read any characters after a LF character. So for
crypting purposes you should use binary operations.

Cant remember if these are in correct syntaxes (too long time without my
beloved Amiga)

Writing:
if openfile(0,"mycryptedfile") ; try to open the output file
a$="mycryptedstring"
; do encrypting here
writemem(0,&a$,len(a$)) ; write the manipulated string to file
closefile(0)
endif

Reading:
if openfile(0,"mycryptedfile") ; try to open the input file
a$=spaces(lof(0)) ; or something so that we have string that's length
matches exactly the length of the data we are going to read
readmem(0,&a$,lof(0)) ; read the manipulated string
closefile(0)
; do decrypting here
endif

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list/-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list/-help@netsoc.ucd.ie