19 January 2019, 15:45 | #1 |
Registered User
Join Date: Dec 2018
Location: UK
Posts: 1,716
|
Variable injection?
Hi,
Is there a better way to inject environment variables, or some other data injection method, when UAE boots up an environment - preferably from a .uae config file. At the moment, I'm using the Volume name (limited to 30 characters) of a mounted device as a method to pass on a text value that can be read by the startup-sequence (using GetVolumeName found on Aminet) Cheers! |
19 January 2019, 16:03 | #2 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
I guess easiest is to add custom config entry to config file (just make sure it is unique enough to not cause conflicts in the future) and use uae-configuration to read it.
|
19 January 2019, 16:16 | #3 | |
Registered User
Join Date: Dec 2018
Location: UK
Posts: 1,716
|
Quote:
I wasn't aware of uae-configuration, but I now see that it comes with ClassicWB LITE - so I'll take a look at this. Thanks once again! Cheers! |
|
19 January 2019, 17:17 | #4 |
Registered User
Join Date: Dec 2018
Location: UK
Posts: 1,716
|
Hi,
Just tried it and it works perfectly! I don't think you can get uae-configuration to return the value of a specific config - I think it just dumps all of it - so I just wrote an Arexx script that parses through the dumped configuration file (in RAM and returns the first matching config entry value. Just need to make sure the config variable is at the top of the config, to minimise the DO WHILE loop time. For anybody that is interested, here's my quick (as in dirty, not as in optimised) ARexx script: Code:
/* GetUAEConfigValue.rexx */ /* Returns the value of a uae config */ /* Requires RAM:uae-configuration */ /* Create the with: */ /* uae-configuration >RAM:uae-configuration */ /* */ /* Usage: rx getuaeconfigvalue <config> */ PARSE ARG config OPEN( 'uae-configuration-fh', 'RAM:uae-configuration', 'R') DO WHILE ~EOF('uae-configuration-fh') line = READLN('uae-configuration-fh') line_lastpos = LASTPOS("=",line) line_length = LENGTH(line) IF (line_lastpos > 1) & ~(line_length == line_lastpos) THEN DO line_config = LEFT(line,line_lastpos-1) line_value = RIGHT(line, (line_length - line_lastpos)) IF (config == line_config) THEN DO SAY line_value RETURN END END END Last edited by solarmon; 19 January 2019 at 17:27. |
19 January 2019, 17:21 | #5 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
uae-configuration <name of config entry> (without <>)
|
19 January 2019, 17:26 | #6 |
Registered User
Join Date: Dec 2018
Location: UK
Posts: 1,716
|
|
19 January 2019, 19:14 | #7 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
It is ultra-minimal program, nothing extra
It can also be used to change config options on the fly. (uae-configuration configentry value) |
19 January 2019, 20:08 | #8 |
Registered User
Join Date: Dec 2018
Location: UK
Posts: 1,716
|
Do you know why it would be returning a failure code of 10 if I try to use it with the backticks method to set an environment variable? See attached image.
I can set environment variables OK, and I can use output redirection to ENV: OK to. Howver, using the backticks method it does return the correct result, but fails with a return code of 10. |
19 January 2019, 22:48 | #9 |
Registered User
Join Date: Dec 2018
Location: UK
Posts: 1,716
|
It seems that when you use the uae-configuration command in a shell script, or with backticks from the shell, it throws this error. Running the command directly and normally from a shell/cli does not seem to cause this issue.
(I also noticed that the output for a config value (when redirected to a file) has a Line Feed at the end of it. I'm not sure whether this is intentional, or a common thing on the Amiga?) |
19 January 2019, 22:49 | #10 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
|
[QUOTE=solarmon;1298789]
Code:
PARSE ARG config OPEN( 'uae-configuration-fh', 'RAM:uae-configuration', 'R') DO WHILE ~EOF('uae-configuration-fh') PARSE VALUE READLN('uae-configuration-fh') WITH line_config '=' line_value IF config == line_config THEN DO SAY line_value RETURN END END |
19 January 2019, 23:02 | #11 |
Registered User
Join Date: Dec 2018
Location: UK
Posts: 1,716
|
[QUOTE=idrougge;1298861]
Thanks! I didn't realise you could use PARSE in this way. Great tip! |
20 January 2019, 08:59 | #12 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
Wrong error code even when matching entry was found will be fixed in next version (it is uae-side bug, also fixed in winuae.7z)
I am not sure if it is safe (= if someone expects it and uses it in scripts) to not output LF when program runs in non-interactive mode but it would be easy update. |
20 January 2019, 12:05 | #13 | |
Registered User
Join Date: Dec 2018
Location: UK
Posts: 1,716
|
Quote:
I'll dump it to RAM and use my ARexx script until it gets fixed. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vbcc bind a variable to a register | iliak | Coders. Asm / Hardware | 6 | 31 July 2016 12:29 |
Join variable and string in scripts. | olesio | support.Apps | 3 | 31 January 2013 11:44 |
Speedy. The variable speed accellerator. | DDNI | Hardware mods | 9 | 18 June 2012 21:33 |
NTSC variable-length scanlines | TheDarkCoder | Coders. Asm / Hardware | 3 | 23 November 2011 15:51 |
Variable Master Clock | wiltshireguyuk | request.UAE Wishlist | 0 | 13 December 2004 16:40 |
|
|