Snippets

A collection of  LiveCode snippets collected from various sources

Files

Auto Save

Auto saves a stack every 10 mins

on openstack
dosave
end openstack
on dosave
save this stack
send dosave to me in 600 seconds
end dosave

Load Image From Stack Sub Directory

on mouseUp
local tMyPath
local tFile
set the itemDelimiter to "/"
put (item 1 to -2 of the effective fileName of this stack) & "/images/" into tMyPath
-- tMyPath now contains the path to your stack and sub folder images
put tMyPath & "myImage.jpg" into tFile
-- tFile contains the full path to your image
put  Url ("binfile:" & tFile) into image "Image1"
-- "binfile:" tell the stack that it is expecting data in binary format
end mouseUp

Network

Get Network PC Names

put shell("net view")

Get User ID

put shell("net user")

Get Current User Name

set the itemDel to "\"
put item 3 of line 2 of shell("net user") into fld "FldUser"

Get IP Address

on mouseUp
answer "IP Address is" && ip.address()
end mouseUp
function ip.address
local pos, temp
put URL "http://whatismyipaddress.com/" into temp
replace space with empty in temp
put offset("script-->",temp) into pos
delete char 1 to pos + 9 in temp
put offset("<!--",temp) into pos
delete char pos to 9999 in temp
replace cr with empty in temp
replace "&#46;" with "." in temp
return temp
end ip.address

Hardware

Get Active System HD Serial Number

on mouseUp
put $systemdrive into tSysDrive
//string for the shell command
put "vol " & tSySDrive into tDriveInfo
//the last word of the returned info is the ACTIVE  SYSTEM HD Serial
set the hideConsoleWindows to true
put the last word of shell(tDriveInfo) into tHDSerial
answer "HD Serial is  " && tHDSerial with "OK"
end mouseUp

Get all Win System info

set the hideConsoleWindows to true
put shell ("systeminfo")

Get Total Memory

set the hideConsoleWindows to true
put shell ("systeminfo | find " & quote& "Total Physical Memory"& quote)

Get Available Memory

set the hideConsoleWindows to true
put shell ("systeminfo | find " & quote& "Available Physical Memory"& quote)