Re: The Great Computer Language Shootout

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sun, 9 Nov 2003 00:32:45 -0500, Irv Mullins <irvm at ellijay.com>
wrote:

>> >>>  8. Ability to print out its own version number.
>
>Suppose your Euphoria program requires features which are found only in 2.4. 
<snip>

I think I'm in a silly mood, it's difficult to tell blink

Anyway, [drum roll and trumpets please] you can knock that one off the
list...

include wildcard.e
object path
integer lp
integer fn
sequence version
integer lv

path=lower(command_line())
if equal(path[1],path[2]) then
	-- if program is bound, we don't care what version
	-- or even whether euphoria is installed or not.
	puts(1,"bound?")
	if getc(0) then end if
	abort(0)
end if
path=getenv("EUDIR")
if atom(path) then
	path=command_line()
	path=lower(path[1])
	lp=length(path)
	if lp>7 and equal(path[lp-6..lp],"exw.exe") then
		lp-=7
	elsif lp>6 and equal(path[lp-5..lp],"ex.exe") then
		lp-=6
	elsif lp>2 and equal(path[lp-1..lp],"eu") then	-- untested
		lp-=2
	else
		puts(1,"unknown executable\n")
		if getc(0) then end if
		abort(0)
	end if
	if lp<5
	or not find(path[lp],"\\/")
	or not equal(path[lp-3..lp-1],"bin")
	or not find(path[lp-4],"\\/") then
		puts(1,"bin dir not recognised\n")
		if getc(0) then end if
		abort(0)
	end if
	path=path[1..lp-5]
end if
path&="\\include\\get.e"
fn=open(path,"r")
if fn=-1 then
	printf(1,"error opening %s\n",{path})
	if getc(0) then end if
	abort(0)
end if
version=gets(fn)
close(fn)
lv=length(version)
while find(version[lv],"\r\n") do
	lv-=1
end while
version=version[lv-2..lv]
if not equal(version,"2.4") then
	printf(1,"Version is:%s\n",{version})
	puts(1,"upgrade required\n")
	if getc(0) then end if
	abort(0)
end if


Maybe Rob can add this to misc.e
<Chuckle>
Pete
http://palacebuilders.pwp.blueyonder.co.uk/euphoria.html

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu