|
*EXEC |
|
andrew (16:48 26/8/2004) ksattic (18:24 26/8/2004) andrew (22:52 26/8/2004) monkeyson2 (01:28 27/8/2004) andrew (13:48 27/8/2004) monkeyson2 (14:44 27/8/2004) andrew (16:24 27/8/2004) adrianl (09:54 31/8/2004) Loris (15:59 31/8/2004) monkeyson2 (17:11 31/8/2004) monkeyson2 (17:13 31/8/2004) andrew (09:53 1/9/2004) andrew (16:26 1/9/2004) mavhc (20:05 1/9/2004) Loris (12:43 2/9/2004) monkeyson2 (13:06 2/9/2004) andrew (14:10 2/9/2004) andrew (16:45 4/9/2004) mavhc (20:11 1/9/2004) andrew (23:13 1/9/2004) mavhc (01:12 2/9/2004)
|
|
Andrew |
Message #57573, posted by andrew at 16:48, 26/8/2004 |
Handbag Boi
Posts: 3439
|
I'm trying to *EXEC a lot of variable definitions into memory to save on listing space in the main program. How do I make the file terminate itself as at the moment I have to press <Return> to get the definitions into memory? |
|
[ Log in to reply ] |
|
Simon Wilson |
Message #57585, posted by ksattic at 18:24, 26/8/2004, in reply to message #57573 |
Finally, an avatar!
Posts: 1291
|
I'm trying to *EXEC a lot of variable definitions into memory to save on listing space in the main program. How do I make the file terminate itself as at the moment I have to press <Return> to get the definitions into memory? |M (bar M) comes to mind from my BBC days...I don't really understand what you're trying to do, though. |
|
[ Log in to reply ] |
|
Andrew |
Message #57602, posted by andrew at 22:52, 26/8/2004, in reply to message #57585 |
Handbag Boi
Posts: 3439
|
I'm trying to load a line of data definitions by *exec to the cursor e.g. l%=0:sdf%=0:bf%=0:d%=5:to%=50 etc and anything else in the initialisation procedure that will save having it in the main listing and thus using up memory. In a similar sense you can INPUT# and BGET# data from file into arrays so that you don't have DATA statements using up your memory. However *EXEC just spools the file to the cursor but won't press return even with |M so I'm wondering how to insert a control character if it is possible into a *exec stream. |
|
[ Log in to reply ] |
|
Phil Mellor |
Message #57603, posted by monkeyson2 at 01:28, 27/8/2004, in reply to message #57602 |
Please don't let them make me be a monkey butler
Posts: 12380
|
The control characters are inserted by, erm, using those characters! So for a new line you enter a new line!
---- snippity ---- *BASIC LOAD "EXAMPLE" F%=12:P$="FOO" RUN ---- snippity ----
Set its filetype to Command (&FFE).
In your run file have *EXEC <Andrew$Dir>.ExecFile
I expect the program would have to issue an OSCLI("EXEC") somewhere near the start to stop the file and reallow keyboard input.
EDIT: remove smileys
[Edited by monkeyson2 at 02:28, 27/8/2004] |
|
[ Log in to reply ] |
|
Andrew |
Message #57625, posted by andrew at 13:48, 27/8/2004, in reply to message #57603 |
Handbag Boi
Posts: 3439
|
That works under RISC OS but not on the Beeb oddly. You still have to press return yourself. I know what has to be done - you have to *BUILD it but it's v.weird as looking at the file in StrongEd the original datafile and the *BUILD file are identical and in filetype!
Here's the next problem - the BASIC program goes rushing ahead of the *EXEC statement before it's worked, is there a way of stopping this?
[Edited by andrew at 15:23, 27/8/2004] |
|
[ Log in to reply ] |
|
Phil Mellor |
Message #57626, posted by monkeyson2 at 14:44, 27/8/2004, in reply to message #57625 |
Please don't let them make me be a monkey butler
Posts: 12380
|
That works under RISC OS but not on the Beeb oddly. You still have to press return yourself. I know what has to be done - you have to *BUILD it but it's v.weird as looking at the file in StrongEd the original datafile and the *BUILD file are identical and in filetype! But do they have the same line endings? RISC OS uses LF, but I suspect *BUILD generates CR+LF.
Here's the next problem - the BASIC program goes rushing ahead of the *EXEC statement before it's worked, is there a way of stopping this?
What do you mean? Are you *EXECing the file from within BASIC? Because I don't think you can do that. You might have to that old trick of defining a function key (*KEY) to do the *EXEC and simulating the keypress (*FX something). Lots of old electron (and beeb?) programs did it to relocate PAGE after loading. Refer to your nearest Electron User listing. |
|
[ Log in to reply ] |
|
Andrew |
Message #57627, posted by andrew at 16:24, 27/8/2004, in reply to message #57626 |
Handbag Boi
Posts: 3439
|
Yes it's a CR according to StrongED as opposed to LF. I can't find the *FX to simulate a key press although I think that might would do it. However, storing lines of BASIC in the function keys would use up memory as well. I think the *Exec doesn't work as it just means send file to keyboard input so BASIC works through the program until it finds an input and consequently inserts gobbledegook to the first INPUT statement in my program |
|
[ Log in to reply ] |
|
Adrian Lees |
Message #57635, posted by adrianl at 09:54, 31/8/2004, in reply to message #57627 |
Member
Posts: 1637
|
I can't find the *FX to simulate a key press although I think that might would do it. *FX138,0,<code> eg. 65 for 'A', 128 for F0 (*Key 0), 129 for F1... This *FX code is a general call to insert a byte into a buffer, 0 being the keyboard input buffer. |
|
[ Log in to reply ] |
|
Tony Haines |
Message #57652, posted by Loris at 15:59, 31/8/2004, in reply to message #57602 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
How many variable definitions do you have? It must be a lot otherwise it is overkill. (Having a lot of small files wastes a lot of space on hard-disk.)
Can you not define the data in a simple format and then load and process it from Basic? something like:
REPEAT INPUT# handle%,variable$,value% statement$=variable$+"="+STR$(value%) EVAL statement$ UNTIL variable$="end"
I just made up the above and it probably contains bugs - it has been a while since I've done this sort of thing. In particular I'm not sure STR$() creates a text string from a number. Also it might not work, I've never used EVAL in anger. If this would be OK except that you also need other variable types or arrays, then you could add a variable type indicator and then a CASE statement. |
|
[ Log in to reply ] |
|
Phil Mellor |
Message #57654, posted by monkeyson2 at 17:11, 31/8/2004, in reply to message #57652 |
Please don't let them make me be a monkey butler
Posts: 12380
|
Are you writing this for a Beeb or an Arc?
You could do the initialisation in the main program, and then use the OVERLAY command to overwrite the initialistation lines with useful procedures and stuff. |
|
[ Log in to reply ] |
|
Phil Mellor |
Message #57655, posted by monkeyson2 at 17:13, 31/8/2004, in reply to message #57654 |
Please don't let them make me be a monkey butler
Posts: 12380
|
Another idea. If you use the variables A%, B%, C%... to Z% you can set these in one basic program, and the values will be remembered even when you CHAIN the next one. But saving 26 initialisations isn't much of a saving. |
|
[ Log in to reply ] |
|
Andrew |
Message #57691, posted by andrew at 09:53, 1/9/2004, in reply to message #57655 |
Handbag Boi
Posts: 3439
|
Another idea. If you use the variables A%, B%, C%... to Z% you can set these in one basic program, and the values will be remembered even when you CHAIN the next one. But saving 26 initialisations isn't much of a saving. For a Beeb. I'm inputting an BGETing most variables although I'll try that EVAL and post back if it works. Making more use of the A-Z integers might be handy as well as that 26 would probably be increased two fold after listing them in the main program. |
|
[ Log in to reply ] |
|
Andrew |
Message #57706, posted by andrew at 16:26, 1/9/2004, in reply to message #57691 |
Handbag Boi
Posts: 3439
|
Sadly EVAL wouldn't do that. Still I've managed to save a fair number of bytes using the integer variables which is a bonus when memory is tight. Obviously the program isn't that big it's just on top of the data it becomes short v.quickly.
One thing I've noticed is that integers seem to use up 8 bytes on BASIC II and 12 bytes on BASIC V. I would have though 2 bytes and 4 bytes respectively? |
|
[ Log in to reply ] |
|
Mark Scholes |
Message #57719, posted by mavhc at 20:05, 1/9/2004, in reply to message #57706 |
Member
Posts: 660
|
well you've got to have space to store the variable name. Ints always take up 4bytes themselves, Reals 5 bytes except in basic 6 where it's 8 |
|
[ Log in to reply ] |
|
Mark Scholes |
Message #57720, posted by mavhc at 20:11, 1/9/2004, in reply to message #57691 |
Member
Posts: 660
|
A%-Z% and @% take up 0 extra RAM on the BBC |
|
[ Log in to reply ] |
|
Andrew |
Message #57727, posted by andrew at 23:13, 1/9/2004, in reply to message #57720 |
Handbag Boi
Posts: 3439
|
Yes I can probably look that up - I'm assuming the SIB is address and variable name? Are you sure about the other var's taking up no extra RAM? Where are they, zero page (i.e. <PAGE)? Also messing with @% is unwise isn't it? |
|
[ Log in to reply ] |
|
Mark Scholes |
Message #57731, posted by mavhc at 01:12, 2/9/2004, in reply to message #57727 |
Member
Posts: 660
|
Yes I can probably look that up - I'm assuming the SIB is address and variable name? Are you sure about the other var's taking up no extra RAM? Where are they, zero page (i.e. <PAGE)? Also messing with @% is unwise isn't it? SIB?
They're allocated a page in RAM already. Zero page is bytes 0-255, 0 to FF. Then you have various buffers for strings, input, etc, then PAGE.
@% affects PRINTing of numbers. |
|
[ Log in to reply ] |
|
Tony Haines |
Message #57742, posted by Loris at 12:43, 2/9/2004, in reply to message #57706 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
Sadly EVAL wouldn't do that. Really? How rigorously did you check? There is something on this webpage which suggests that it will work for assignment. (Search for 'Cunning Stunts') |
|
[ Log in to reply ] |
|
Phil Mellor |
Message #57743, posted by monkeyson2 at 13:06, 2/9/2004, in reply to message #57742 |
Please don't let them make me be a monkey butler
Posts: 12380
|
Sadly EVAL wouldn't do that. Really? How rigorously did you check? There is something on this webpage which suggests that it will work for assignment. (Search for 'Cunning Stunts') OOh, I like that. That's clever. |
|
[ Log in to reply ] |
|
Andrew |
Message #57746, posted by andrew at 14:10, 2/9/2004, in reply to message #57743 |
Handbag Boi
Posts: 3439
|
Well, after trying to send a few simple expressions with strings such as: EVAL("x$") and getting Syntax Error, AS I get with that program I thought it would not be possible!
[Edited by andrew at 15:11, 2/9/2004] |
|
[ Log in to reply ] |
|
Andrew |
Message #57766, posted by andrew at 16:45, 4/9/2004, in reply to message #57746 |
Handbag Boi
Posts: 3439
|
I should say that as Monkeyson said the soft-key definitions /are/ apparently stored below BASIC user workspace so it might be an idea trying to store things there although I'm not sure how they're stored or if they're replaced after CHAIN. Not changed after <Break> though so it's promising |
|
[ Log in to reply ] |
|
|