|
Post by MadModder on Oct 21, 2006 13:17:22 GMT -5
Is it possible to open a file from within a basic program and load the contents into a memory location or into some variables, without using get# or input# ?
|
|
|
Post by Robin Harbron on Oct 21, 2006 13:28:23 GMT -5
Is it possible to open a file from within a basic program and load the contents into a memory location or into some variables, without using get# or input# ? You could just use LOAD from within a program. The only trick is that program execution starts over at the first line after the load is complete, but variables are left intact. So: 10 IF F=0 THEN F=1: LOAD "SOMETHING",8,1 20 REM PROGRAM CONTINUES If you don't do the IF, the program would endlessly loop.
|
|
|
Post by MadModder on Oct 21, 2006 14:06:54 GMT -5
Yes, I know. The problem is that the first two bytes must point to the right memory location, and my DTV doesn't like loading files like that. Somehow it just crashes when I continue coding, so it's kind of problematic to test a program under development...
|
|
|
Post by Robin Harbron on Oct 21, 2006 20:22:58 GMT -5
Why didn't you say so then? Hmm, are you loading from device 8? Sounds like something that would happen with device 1. I remember reading in some issue of Loadstar how to use a KERNAL SYS to load a file - that might have the same problem anyway. And I'd probably have to look through 50 issues to find the right one
|
|
|
Post by MadModder on Oct 22, 2006 7:23:38 GMT -5
Yes, from device 8. Oh well. I'll use the real 1541 instead of the 1541-III until it supports sequential stuff.
|
|
|
Post by Jim Lawless on Oct 24, 2006 6:14:57 GMT -5
I could throw together a small ML routine to do this that could live in the cassette buffer ... unless you absolutley need BASIC or a KERNAL routine.
|
|
|
Post by MadModder on Oct 24, 2006 10:26:35 GMT -5
Well, thanks. I don't do ML, but if I could call it from basic then I guess it would be fine.
|
|
|
Post by Leif Bloomquist on Oct 24, 2006 10:31:10 GMT -5
You could just use LOAD from within a program. The only trick is that program execution starts over at the first line after the load is complete, but variables are left intact. Isn't there a SYS call that you can use instead, that doesn't restart the program?
|
|
|
Post by Robin Harbron on Oct 24, 2006 13:07:07 GMT -5
Isn't there a SYS call that you can use instead, that doesn't restart the program? Yeah, that's what I was referring to in my follow-up comment about an issue of Loadstar that describes this. I'll see if Dave knows how to find it...
|
|
|
Post by Pinacolada on Oct 24, 2006 15:26:51 GMT -5
Here's some code, taken from my game which I just happened to have handy... 4000 rem load "input any" ml4001 ifpeek(49152)=32thenreturn 4003 sys57812"ia",dv,1:rem setlfs in kernal sets parameters 4004 poke780,0:sys 65493: rem load 4005 returnSomething like that help, maybe?
|
|
|
Post by Robin Harbron on Oct 26, 2006 0:05:06 GMT -5
Thanks, Ryan. Dave wrote me back, so I might as well post his info too: SYS57812"FILENAME",DV,0 POKE780,0 POKE781,LOBYTEADDR POKE782,HIBYTEADDR SYS65493 "This and a zillion pieces of information will be published in the next LOADSTAR (247) in the hypertext ENCYCLOPEDIA COMMODOREA, a collection of most of the useful hints and tips for the C-64." - Dave I'm looking forward to issue #247
|
|
|
Post by metalfoot on Oct 26, 2006 23:06:19 GMT -5
I'm also looking forward to 247, if Dave publishes what I sent him...!
|
|
|
Post by Pinacolada on Nov 1, 2006 14:26:22 GMT -5
Hey, cool. I knew I forgot something... heh. ?TOO LITTLE COFFEE ERROR
|
|
|
Post by mrloadstar on Feb 10, 2007 22:15:00 GMT -5
Is it possible to open a file from within a basic program and load the contents into a memory location or into some variables, without using get# or input# ? You could just use LOAD from within a program. The only trick is that program execution starts over at the first line after the load is complete, but variables are left intact. So: 10 IF F=0 THEN F=1: LOAD "SOMETHING",8,1 20 REM PROGRAM CONTINUES If you don't do the IF, the program would endlessly loop. While this certainly works, bloading is much more controllable with the following code: SYS57812"FILE",dv,0:POKE780,0:POKE781,LO:POKE782,HI:SYS65493 Loc 780 is 0 for load, 1 for verify. With this, you can bload data anywhere in memory, not just to the address from which it was saved. (For ML, you have to bload to the assembled address.) Also, this rather long line does not return the program to the top. It is almost a real BLOAD command. Now to get the data -- 10 A$=STR$(PEEK(71)+256*PEEK(72)):A=VAL(A$) A is now the pointer to the string data, and can be pointed anywhere in open memory. POKEA,len POKEA+1,ADDRLO POKEA+2,ADDRHI Magically, A$ will now hold len bytes of whatever is at ADDR. How you make this work is up to you. Static length Fields is one way. Long ago, I created a database using the $C0000 4K area (49152-53247) for data, and the above moveable string to get information into BASIC. Had to POKE data byte-by-byte into the memory area, though. Dave
|
|