D7WS HOMEPAGE WORKSHOP NEUE XTRAS GALERIE WORKSHOP Automatic Translation LESERSERVICE BUCH NEWS

HowTo: Macintosh Gestalt Values

 

 

 

Home
Workshop-Seite

Deutsche Version

Download
gestalt.sit

Gestalt can be used to get most of the Mac-internal properties such as RAM installed, System and QuickTime versions, Open Transport, Remote Access, AppleScript versions and status and many more. It's hard to find a really comprehensive list of the Gestalt Descriptors, though. The only useable is here (download link).

When calling gestalt, the respective values may be returned in several different formats – the script below interpretes some of them, but not all. If you've downloaded the Gestaltlab application with the above link you'll see what I mean with "different formats"...

I started this script with an old Xtra called AppleScriptXtra (which is superseeded by the zScript Xtra; buy/download demo from Zeus productions) and sent one-line AppleScripts to get single gestalt values. It's not the fastest way, but it works.

Then I tried the same thing with Buddy Api's baGestalt() function – nice and a bit faster... The same with OSUtil. BTW: these gestalt selectors are the way to teach buddy api or OSUtil to retrieve information it has no explicit function for, or even information about future features of the MacOS. The below script (down the page) is able to use either BuddyApi (preferred) or the AppleScriptXtra. Other Xtras might be plugged in also if they are able do gestalt calls or to send AppleScripts and receive their return values. In the downloadable movie, I integrated OSUtil and zScript, too.




 

 

 

 

This is the list I use in the downloadable example (after deleting the returns...): the gestalt selectors are the four char strings right after the features' explanation. Don't leave out the spaces – it's necessary to write "vm  "!

[
"PowerPC": ["ppc ", #bool, #int],
"CPU-Typ": ["cput", #int],
"Maschinentyp": ["mach", #int],
"Busspeed in Hz": ["bclk", #int],
"RAM in Bytes": ["ram ",#int],
"Virtueller Speicher": ["vm ", #bool],
"Logisches Ram in Bytes": ["lram", #int],
"Systemversion": ["sysv", #base16],
"OS": ["os ", #int],
"Quicktime-Version": ["qtim", #numVers],
"QuickTime Power-Plug": ["qtrs", #bool],
"QuickTime VR 2": ["qtvr", #bool],
"QuickTime VR-Version": ["qtvv", #numvers],
"Open Transport": ["otan", [1: "OT present", 2: "OT loaded", 4: "AppleTalk present", 8: "AT loaded", 16: "TCP present", 32: "TCP loaded", 64: "IPXSPX present", 128: "IPXSPX loaded"]],
"Remote Access": ["otra", [1: "RA present", 2: "RA loaded", 4: "Client only", 8: "PServer", 16: "MPServer", 32: "PPP present", 64: "ARA present"]],
"Open Transport-Version": ["otvr", #numvers],
"Filesystem": ["fs ", #int],
"AppleScript": ["ascr", [0: "AS present", 1: "PowerPC support"]],
"AppleScript-Version": ["ascv", #numVers],
"Event-Support": ["evnt", [1: "AE present", 2: "Scripting Support", 4: "OSL in System"]],
"Audio-CD-Support": ["aucd", #bool, #base16]
]




 

 

 

 

This is a movie Script. Strip the returns from above list and put it into member "Gestalt Selectors". Have a text member "display" on-stage. Then just type getsysprofile in the message window. ––– Or use the downloadable example ;-) You ay also use getgestalt() directly; pass it a gestalt selector and a symbol for the xtra to use (#AS or #BUD): put getgestalt("otan", #BUD).

BTW: The script does NO error checking to see whether a gestalt value exists or not. It will most likely return zero if the gestalt selector is not present on a particular machine.

-- uses a premade gestalt selectors & formatting table
-- stored in member "Gestalt Selectors"
-- places output into text member "display"

global myinst


-- checks for Xtra availability, sets the output formatting
-- and calls the gestalt engine for information
on getsysprofile anXtra
  -- plug-in other Xtras here and in getgestalt()
  if checkXtra ("Buddy API Xtra") and not(anXtra = #AS) then
    anXtra = #Bud
  else if checkXtra ("AppleScriptXtraFat") then anXtra = #AS
  else
    alert "Neither BudAPI nor AppleScriptXtra are present. This script won't work."
    return
  end if
  sellist = value(member("Gestalt Selectors").text)
  max = sellist.count()
  member("display").text = ""
  repeat with i = 1 to max
    member("display").text = member("display").text & RETURN & ¬
sellist.getpropat(i)&": "
    member("display").text = member("display").text & ¬
evalGestalt(sellist[i], anXtra)
    updatestage
  end repeat
  cleanupXtra
end

-- Xtra independent gestalt call & formatting call
on evalGestalt aList, WhichXtra
  gestaltval = getgestalt(aList[1], whichXtra)
  gestaltform = aList
  return transform(gestaltval, gestaltform)
end

-- get the raw gestalt value with the xtra available
-- AppleScriptXtra or BudAPI
on getgestalt which, whichxtra
  if whichXtra = #Bud then return baGestalt(which)
  else if whichxtra = #AS then
    scrtext = "tell application "&quote&"Finder"&quote & ¬
" to return computer "
    scrtext = scrtext & quote & which & quote
    return evalAS(scrtext)
  end if
end

-- AppleScriptXtra function
on evalAS aText
  if voidP(myinst) then myinst = new(xtra "AppleScriptXtra")
  myinst.setScriptText(atext)
  myinst.run()
  retval = myinst.getresult()
  return retval
end

-- Close Xtra
on cleanupXtra
  if voidp(myinst) then return
  myinst.forget()
  myinst = VOID
end

-- Transforms the raw gestalt value into human readable form (needs
-- work)
-- The info for interpretion is stored in the text member "Gestalt
-- Selectors"
on transform myval, aList
  myform = aList[2]
  case TRUE of
    (myform = #int):
      return string(myval)
    (myform = #bool):
      temp = "nein"
      if myval > 0 then temp = "ja"
      if aList.count() > 2 then
        if aList[3] = #int then return temp && ",Wert: "&string(myval)
        else if aList[3] = #base16 then return temp && ¬
",Wert: "&base16(myval)
        else return temp
      else
        return temp
      end if
    (myform = #base16):
      return string(base16(myval))
    (myform = #numVers):
      return string(getNumVers(myval))
    (listP(myform)):
      return string(getbytes(myval, myform))
  otherwise
    return "unknown format"
  end case
end

-----------------------------------
-- Helper functions for transform()
-----------------------------------
on getBytes anint, aform
  temp = []
  repeat with i = aform.count() down to 1
    if anint >= aform.getpropat(i) then
      temp.append(aform[i])
      anint = anint - aform.getpropat(i)
    end if
  end repeat
  temp2 = ""
  repeat with i = temp.count() down to 1
    temp2 = temp2 & temp[i] & ", "
  end repeat
  return temp2.char[1..temp2.length - 2]
end

on getnumVers anint
  set the itemdelimiter = "."
  myretval = base16(integer(item 1 of base16(anint)))
  set temp = item 4 of myretval
  myretval = myretval.char[1..5]
  case integer(temp) of:
    8: myretval = myretval &&"final"
    6: myretval = myretval && "beta"
    4, 2: myretval = myretval && "alpha/development"
  end case
  return myretval
end

on base16 anInt
  x0 = string(integer(anInt)/4096)
  x1 = string((integer(anInt) mod 4096)/256)
  x2 = string((integer(anInt) mod 256) / 16)
  x3 = string(integer(anInt) mod 16)
  return x0&"."&x1&"."&x2&"."&x3
end

--------------------------------------------------
-- Helper function for checking Xtra availability
--------------------------------------------------
on checkXtra anXtra
  temp = the xtralist
  repeat with i = 1 to temp.count()
    if temp[i].name = anxtra then return TRUE
  end repeat
  --alert "Das Xtra "&quote&&anXtra&quote&" ist nicht vorhanden."
  return FALSE
end

Joachim Gola




 


Directorworkshop.de ist © Joachim Gola & Gerd Gillmaier 1998-2002. Alle Rechte vorbehalten.