Ultimate Amiga
Network Boards => AMOS Language Discussion => AMOS Factory => AMOS The Creator Forum => Topic started by: BooBoo on February 19, 2008, 11:53:17 AM
-
Hi I hope all is well in Amos land
I like to load and display a TxT file for a basic Menu
Basicly my txt file looks like
1 Chaos Engine
2 Toki
3 Mercs
E.t.c
and my Amos Prog looks like
Dir$="dh0:"
Open In 1,"Menu.TXT"
Input #1,A$
Print A$
Close 1
But this only displays the first line of my list is possible to display all the list?
-
Try this:
Dir$="dh0:"
Open In 1,"Menu.TXT"
While Not Eof(1)
Line Input #1, A$
Print A$
Wend
Close 1
-
Thank You - yes this Works :) - Ive still got some problems and would appreciate further advice
This is the Code ive got so far
A=0
Pen 2 : Curs Off : Paper 0 : Cls 0 : Paper 0 : Hide
Pen 2 : Locate 0,0
Dir$="dh0:"
Open In 1,"Menu.TXT"
While Not Eof(1)
Line Input #1,A$
Print A$
Wend
Rem Print A
10 Pen 3 : Locate 1,A : Print ">"
Pen 2 : Locate 1,A+1 : Print " "
If A>0 Then Pen 2 : Locate 1,A-1 : Print " "
Do
If Jdown(1) Then Wait 5 : A=A+1 : Goto 10
If Jup(1) Then Wait 5 : If A>0 Then A=A-1 : Goto 10
If Fire(1) Then Goto 20
Loop
20Dir$="Dh0:"
B=A+1
Open Out 2,"Run"
Print #2,"Execute";B
Close 1
End
So the idea is it exports a simple TxT file called Run "Execute 2" which is then Executed by AmigaDos but the file its exports allways has a problem it wont execute corectly But I know if I create the same file in ED it works? any ideas?
-
amiga txt files for sripts are slightly different to normal txt files... check its using a value of $50 (i think) to declare the end of a line - i know i've tripped over this a few times, with scripts refusing to run!
-
Yes I think your right I not sure how i can check this - But I had a similar problem when Editing my Startup-Sequence from WindowZ in both cases opening the Script with ED and re-saving with no changes solved the problem -Ive tryed adding "Set Input 10,-1" to my code but this only seems to help when loading a txt file not exporting so im still stuck?
-
I found a way round it Im useing a tool from aminet called Feeder - End-of-line to LF ASCII text converter and it works in a Script so no GUI so all Ok - Big Thanks guys for the replys and help thanks to you I now have a Nice games Launcher for my A600 :)
http://aminet.net/util/conv/feeder.lha
-
Try this:
Dir$="dh0:"
Open In 1,"Menu.TXT"
While Not Eof(1)
Line Input #1, A$
Print A$
Wend
Close 1
I'm already using this code, but is there some faster way of loading text files in string array?
Loading 20, 30kB text this way can take few seconds.
-
Does the text vary each time you run it? If not, try converting the strings into Data statements in the code.
-
Text files are the same, but there are quit a few of them, so Data is probably the best solution. But if I divide it in few parts than it loads in decent speed.
-
Why not load them into an AMOS bank? It would take only a second or so to load them in and then you can display them as fast as the peek$ command will allow, unless you prefer using Chr$(Peek(address)).
Regards,
Lonewolf10
-
I don't know how to do that :-[, my knowledge of AMOS is basic. I'm satisfied with loading times when the text is broken in few files, but I'm more than willing to have a look if you have some source code regarding this problem.
-
When using the Peek$() function you can print an entire text file to the screen in one Print command. The disadvantage of it is that you need to know the length of the file before you can print it. Another disadvantage is that you have to know how much memory to reserve in the bank before you can load your data into it.
Here's a really fast way to load and print a text file:
` open the file to get its length
Open Input #1, "filename.txt"
` reserve enough memory in bank 15 to hold the file
Reserve As Work 15, Lof(1)
` we have the length now so we close the file
Close 1
` read the entire file in at once
Bload "filename.txt",15
` print the entire file at once
Print Peek$(Start(15),Length(15))
` free up the memory we stored it in
Erase 15