English Amiga Board


Go Back   English Amiga Board > Support > support.WinUAE

 
 
Thread Tools
Old 19 January 2019, 16:45   #1
solarmon
Registered User

solarmon's Avatar
 
Join Date: Dec 2018
Location: UK
Posts: 481
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!
solarmon is offline  
Old 19 January 2019, 17:03   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 44
Posts: 23,257
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.
Toni Wilen is offline  
Old 19 January 2019, 17:16   #3
solarmon
Registered User

solarmon's Avatar
 
Join Date: Dec 2018
Location: UK
Posts: 481
Quote:
Originally Posted by Toni Wilen View Post
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.
Thanks for the quick response.

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!
solarmon is offline  
Old 19 January 2019, 18:17   #4
solarmon
Registered User

solarmon's Avatar
 
Join Date: Dec 2018
Location: UK
Posts: 481
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 18:27.
solarmon is offline  
Old 19 January 2019, 18:21   #5
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 44
Posts: 23,257
uae-configuration <name of config entry> (without <>)
Toni Wilen is offline  
Old 19 January 2019, 18:26   #6
solarmon
Registered User

solarmon's Avatar
 
Join Date: Dec 2018
Location: UK
Posts: 481
Quote:
Originally Posted by Toni Wilen View Post
uae-configuration <name of config entry> (without <>)
Doh! I tried a 'uae-configuration ?' and it didn't return anything so I didn't try it!

Thanks, that is even better now!
solarmon is offline  
Old 19 January 2019, 20:14   #7
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 44
Posts: 23,257
It is ultra-minimal program, nothing extra

It can also be used to change config options on the fly. (uae-configuration configentry value)
Toni Wilen is offline  
Old 19 January 2019, 21:08   #8
solarmon
Registered User

solarmon's Avatar
 
Join Date: Dec 2018
Location: UK
Posts: 481
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.
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	68
Size:	15.3 KB
ID:	61649  
solarmon is offline  
Old 19 January 2019, 23:48   #9
solarmon
Registered User

solarmon's Avatar
 
Join Date: Dec 2018
Location: UK
Posts: 481
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?)
solarmon is offline  
Old 19 January 2019, 23:49   #10
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,927
[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
idrougge is offline  
Old 20 January 2019, 00:02   #11
solarmon
Registered User

solarmon's Avatar
 
Join Date: Dec 2018
Location: UK
Posts: 481
[QUOTE=idrougge;1298861]

Thanks! I didn't realise you could use PARSE in this way. Great tip!
solarmon is offline  
Old 20 January 2019, 09:59   #12
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 44
Posts: 23,257
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.
Toni Wilen is offline  
Old 20 January 2019, 13:05   #13
solarmon
Registered User

solarmon's Avatar
 
Join Date: Dec 2018
Location: UK
Posts: 481
Quote:
Originally Posted by Toni Wilen View Post
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.
OK - thanks for the confirmation.

I'll dump it to RAM and use my ARexx script until it gets fixed.
solarmon is offline  
 


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 13:29
Join variable and string in scripts. olesio support.Apps 3 31 January 2013 12:44
Speedy. The variable speed accellerator. DDNI Hardware mods 9 18 June 2012 22:33
NTSC variable-length scanlines TheDarkCoder Coders. Asm / Hardware 3 23 November 2011 16:51
Variable Master Clock wiltshireguyuk request.UAE Wishlist 0 13 December 2004 17:40

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:48.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.07945 seconds with 14 queries