FLC_IDE: A combi-function for stack environment info
FlexibleLearning at aol.com
FlexibleLearning at aol.com
Thu Sep 30 07:03:20 EDT 2004
Several rather useful handlers have been posted to identify various aspects
of a stack's operating environment, so I thought to combine them in a single
function for your Scripter's Scrapbooks. The below should copy and paste
correctly as monospaced, but do watch for line wraps!
example: put FLC_IDE()
example: get FLC_IDE(sys,plat,vers)
example: get FLC_IDE(v,e,p)
example: if "dev" is in FLC_IDE(env) then...
The options can be shortened to a single letter and put in any order, and
will be returned in the same order as requested.
Uses: switch, paramCount, params, format, try/catch, do as AppleScript
EXAMPLE:
on mouseUp
put FLC_IDE (p,e,s)
end mouseUp
----------------------------------------------------------------------
--| FUNCTION: FLC_IDE
--|
--| Author: Hugh Senior, based on ideas by Ken Ray, Scott Rossi
and Xavier Bury
--| Version: 1.0
--| Created: 30-SEP-2004
--| Last Mod: --
--| Requires: Self-contained function handler for Revolution and
MetaCard
--|
--| Summary:
--| Returns any combination of the platform, system version,
--| application type, engine version, build number, and environment
--| in a return-separated list
--|
--| Parameters:
--| None (for full list), or
--| Any combination of P[latform], S[ystemVersion], A[pplication],
--| V[ersion], B[uild], E[nvironment]
--| Example: get FLC_IDE() - Returns all 6 lines
--| Example: get FLC_IDE(A,V,P) - Returns Application, Version and
Platform
--| xample: get FLC_IDE(plat,e,s) - Returns Platform, Envt and Sys Vers
--|
--| Returned values:
--| Values will be one per line, in the same order as requested...
--| Platform: Windows 95, Windows 98, Windows ME, Windows NT, Windows
2000,
--| Windows XP, Mac OSX, Mac Classic, Mac OS9, Linux
--| SystemVersion: Your computer OS version
--| Application: MetaCard, Revolution
--| Version: Engine version
--| Build: Engine build number
--| Environment: Development, Helper Application, Standalone Application
--| [or Player], [or Plug-In]
----------------------------------------------------------------------
function FLC_IDE
local tPlatform,tSystemVersion,tApp,tVersion,tBuild,tEnvt
# Platform: Windows 95, Windows 98, Windows ME, Windows NT, Windows 2000,
Windows XP...
if the platform is "Win32" then
put word 2 of the systemVersion into tSystemVersion
if word 1 of the systemVersion = "Windows" then
# set the shellcommand to "command.exe"
switch
case tSystemVersion>=4 and tSystemVersion<4.1
put "Windows 95" into tPlatform
break
case tSystemVersion>=4.1 and tSystemVersion<4.9
put "Windows 98" into tPlatform
break
case tSystemVersion>=4.9
put "Windows ME" into tPlatform
end switch
else
# set the shellcommand to "cmd.exe"
switch
case tSystemVersion>=4 and tSystemVersion<5
put "Windows NT" into tPlatform
break
case tSystemVersion>=5 and tSystemVersion<5.1
put "Windows 2000" into tPlatform
break
case tSystemVersion>=5.1
put "Windows XP" into tPlatform
end switch
end if
else if the platform is "MacOS" then
# Platform: Mac OSX, Mac Classic, Mac OS9
put the systemVersion into tSystemVersion
set the itemDel to "."
if item 1 of tSystemVersion >= 10 then
put "Mac OSX" into tPlatform
else
put format("tell app \"Finder\"\the processes\tell") into tAS
do tAS as AppleScript
put format("process \"Classic Support\"") into tClassicProcName
if (the result contains tClassicProcName) then
put "Mac Classic" into tPlatform
else put "Mac OS9" into tPlatform
end if
else
# Platform: Linux
put "Linux" into tPlatform
end if
# Application: Revolution, MetaCard
# Version: [number]
# Build: [number]
put the buildNumber into tBuild
try
put revAppVersion() into tApp
catch errorVar
put "MC" into tApp
end try
if (tApp is "MC") OR (tVersion is 0) then
put the version into tVersion
put "MetaCard" into tApp
else put "Revolution" into tApp
# Environment: Development, Helper Application, Standalone Application [or
Player], [or Plug-In]
put the environment into tEnvt
if the paramCount is 0 then
return tPlatform &CR&\
tSystemVersion &CR&\
tApp &CR&\
tVersion &CR&\
tBuild &CR&\
tEnvt
else
local temp
repeat with n=1 to the paramCount
switch char 1 of param(n)
case "P"
put tPlatform &CR after temp break
case "S"
put tSystemVersion &CR after temp break
case "A"
put tApp &CR after temp break
case "V"
put tVersion &CR after temp break
case "B"
put tBuild &CR after temp break
case "E"
put tEnvt &CR after temp break
end switch
end repeat
if last char of temp is CR then delete last char of temp
return temp
end if
end FLC_IDE
/H
The Flexible Learning Company
Home of The Scripter's Scrapbook
www.flco.co.uk (note the new shorter web address shortcut)
More information about the use-livecode
mailing list