Ñ ASCII TEXT & EDITORS -------------------- BY RICHARD MARTIN Welcome again all you WAC readers. After last issues Paralax scrolling article I promised you a look at ASCII text files and using an editor of some sort in a game. Well here it is, in one block of text now I understand the WAC engine! But before we start what is ASCII??. Well ASCII stands for AMERICAN STANDARD CODE for INTERGER INTERCHANGE. Quite a complex name,but ASCII has been around for many years. Basically some Amercians wanted to create a file format which was interchangeable between every computer. Well, they have sort of suceeeded, as I could just as easily be typing this in a word processor on my multimedia PC which is sitting next to me. (Apart from I would have to add in my Smart Drive again, then remove it when I wanted to play Nova Storm!). Anyway, the file format of the disks is different so I would have to use Cross Dos. Also Spectrums use ASCII as well, apart from they don't have a 3.5" disk drive. § AMOS calls ASCII text files SEQUENTIAL Files. This is not such a stupid name after all because the files are saved out in sequence. For example If you had three variables: A,B and C. If A=1, B=5 and C=14 the file would look like: 1 5 14 when viewed via a word processor. So, with thi sorted, lets have a look at how to load in an ASCII text file from a WP. You could reserve a bank the same length as the file and then Bload it in, but Memory banks are something to cover later. So, how about this: Set Input 10,-1 Open In 1,MYFILE$ Repeat Input #1,A$ Print A$ Until Eof(1) Close 1. Well, first off Set Input 10,-1. This is vitally important for ASCII files. The default setting skips to a new line when a Comma is found. When it is set to 10,-1 then it finds a carridge return and ends the line there. For example if you typed and saved this into your WP, and then loaded in to the above program this is what would happen. START TEXT: Hello, There , Punk SET INPUT 10,-1: Hello, There , Punk. NORMAL INPUT: Hello There Punk Ï Next up it opens the file into one of its Channels. Then it keeps going down the file line by line until it reaches the end. Every loop it stores the string of text into A$ and then prints it on the screen. Very simple. To save a file it is just as easy: ' Did 'o' Matic Word Processor ' ' Screen Open 0,640,256,2,Hires Cls 0 : Colour 1,$FFF : Paper 0 : Pen 1 Set Input 10,-1 Print "Please Type in your text :" Input A$ Print" Thank you very much. Please type in the File Name!" Input F$ Open Out 1,F$ Print #1,A$ Close 1 End Simple up to now, and this can be very usefull If you wanted to write a util. As an example of an editor util I have given Paul Gumsley the COMPLETE source to Slide Creator - my new PD util. Here are the load and save procedures: Procedure SAV F$=Fsel$("","","Please Select File or ","type in new file to save on") If F$="" Sam Play 2 LINE$(1)="Warning: File could not be saved" LINE$(2)=" << Click Mouse >> " MESSAGE[50,50,450,100,2] Else Open Out 1,F$ Print #1,STMOD$ Print #1,NOSLIDES For I=1 To NOSLIDES Print #1,PIC$(I) Print #1,DELAY(I) Print #1,INFADE(I) Print #1,OUTFADE(I) Print #1,PICHEIGHT(I) Print #1,PICWIDTH(I) Print #1,NOCOLOURS(I) Next I Close 1 LINE$(1)="File Saved Sucessfully." LINE$(2)=" << Click Mouse >>" MESSAGE[50,50,450,100,2] End If End Proc Procedure LOD F$=Fsel$("","","Please Select File ","to Load in and Edit") If F$="" Sam Play 2 LINE$(1)="Warning: File not found error!" LINE$(2)=" << Click Mouse >> " MESSAGE[50,50,450,100,2] Else Open In 1,F$ Input #1,STMOD$ Input #1,NOSLIDES For I=1 To NOSLIDES Input #1,PIC$(I) Input #1,DELAY(I) Input #1,INFADE(I) Input #1,OUTFADE(I) Input #1,PICHEIGHT(I) Input #1,PICWIDTH(I) Input #1,NOCOLOURS(I) Next I Close 1 LINE$(1)="File Loaded Sucessfully." LINE$(2)=" << Click Mouse >>" MESSAGE[50,50,450,100,2] End If End Proc § They save all the infomation needed into a small ASCII file. Then it takes up little disk space, but can be easily re edited and viewed by the external viewer. Here is a file created with Slide Creator: I have written what eacfh piece of information is: ' DF0:MOD.STARTREK : St Module to play. 1 : Number of Pictures in Slide Show DF0:ARTWORK/STARTREK.IFF: First Picture Name. 1000 : How many Vbls to wait. 3 : No for Fade in 4 : No for Fade out 256 : How many Pixels high the screen is (for ed) 320 : " " wide " " 4096 : How Many colours. (This is a nice HAM Pic) Ï The cunning thing about this is the NO pictures variable.The above slideshow has just one picture in it. My creator can have up to 50! Now, I could just write all 50 files but they would just be blanks. So what I do is this to display a picture: Open in 1,Slides.txt Input #1,STMOD$ Track Load STMOD$,3 Track Play 3 Input #1,NOPICS For I=1 to NOPICS | | | | | | Next I Close 1 § It saves a lot of space on disk, and a lot of time. I hope Paul puts my Source on WAC this time.. It is exclusive you know - you won't even find it on DidsMag. (Though I run it) Please write any article suggestions to me at Richard Martin 9 Blundell Ave BirkDale SouthPort PR8 4TA or to Paul at the usual address. Bye Bye