OT - getting the computer's name under OSX
Terry Judd
tsj at unimelb.edu.au
Thu Sep 16 20:11:43 EDT 2004
On Friday, September 17, 2004, at 12:51 AM,
use-revolution-request at lists.runrev.com wrote:
>>> I know I can get the user's name under OSX by querying $user, but how
>>> do I get hold of the computer's name (as given in the Sharing
>>> preferences pane).
>>
>> Here you go:
>>
>> on mouseUp
>> answer ComputerName()
>> end mouseUp
>>
>> function ComputerName
>> local tName
>> put shell("system_profiler SPSoftwareDataType") into tData
>> get matchText(tData,"(?s)Computer Name:\W*(.*?)\n",tName)
>> if it is true then
>> return tName
>> else
>> return "Error: Can't locate computer name."
>> end if
>> end ComputerName
>
> Now that I'm thinking about it, there's a much easier way:
>
> function ComputerName
> set the itemDel to ":"
> return (item 1 of the address)
> end ComputerName
So easy!
Thanks (again) Ken.
Cheers,
Terry...
>
> Ken Ray
> Sons of Thunder Software
> Web site: http://www.sonsothunder.com/
> Email: kray at sonsothunder.com
>
Dr Terry Judd
Lecturer in Educational Technology (Design)
Biomedical Multimedia Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne
Parkville VIC 3052
AUSTRALIA
More information about the use-livecode
mailing list