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 "." 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)
Fields
Drag lines in field
on mouseDown
--setup colors for hilited text
put "black" into tOrigCol
put "red" into tHiLiteCol
put word 2 of the clickLine into tClickLine
if line tClickLine of me is empty then
exit mousedown
end if
put item 2 of the mouseLoc into tStartLIne
put the effective textHeight of me into tHt
repeat while the mouse is down
--down
if item 2 of the mouseLoc - tStartLIne > (tHt/2) then
lock screen
put cr & line tClickLine of me after line tClickLine + 1 of me
delete line tClickLine of me
add 1 to tClickLine
set the textcolor of line tClickLine of me to tHiLiteCol
add tHt to tStartLIne
unlock screen
--up
else if tStartLIne - item 2 of the mouseLoc > (tHt/2) then
lock screen
put line tClickLine of me & cr before line tClickLine - 1 of me
delete line tClickLine + 1 of me
subtract 1 from tClickLine
set the textcolor of line tClickLine of me to tHiLiteCol
subtract tHt from tStartLIne
unlock screen
end if
end repeat
--protect against empty lines being inserted
filter lines of me without empty
--make sure all lines are reset to original text color
put the number of lines of me into tNoLines
repeat with tC = 1 to tNoLines
set the textcolor of line tC of me to tOrigCol
end repeat
end mouseDown