Skip to content

Instantly share code, notes, and snippets.

@AndyPiddock
AndyPiddock / Drag non decorated stack.livecode
Last active August 28, 2018 11:12
Drag non decorated stack
local sgLeftOffset
local sgTopOffset
local sgDragging
on mouseDown
put item 1 of the mouseLoc into sgLeftOffset
put item 2 of the mouseLoc into sgTopOffset
put true into sgDragging
end mouseDown
@AndyPiddock
AndyPiddock / load library stack.livecode
Last active August 28, 2018 11:14
LiveCode: loads a library stack invisibly for use by a calling stack and makes it ready to use
--Loads a library stack invisibly for use by a calling stack and makes it ready to use
local tPath
lock screen
//loads the library from disk and inserts it as a library
set the itemDel to "/"
put the effective filename of stack "myMainStack" into tPath
put "MyLibraryStack.livecode" into item -1 of tPath
open invisible stack tPath
@AndyPiddock
AndyPiddock / hide files and folders.livecode
Last active August 28, 2018 11:15
LiveCode: hide files and folders - windows
--thePaths contains a cr delimited list of valid file/folder path
set the hideconsolewindows to true
put empty into tErrors
repeat for each line tPath in thePaths
put theFolder&tPath into tPath
if last char of tPath = slash then
delete last char of tPath
end if
replace "/" with "\" in tPath
@AndyPiddock
AndyPiddock / auto saves a stack.livecode
Last active August 28, 2018 11:15
LiveCode: auto saves a stack every 10 min
--Auto saves a stack every 10 mins, easy to convert to save files
on openstack
dosave
end openstack
on dosave
save this stack
send dosave to me in 600 seconds
end dosave
@AndyPiddock
AndyPiddock / Auto Update stack.livecode
Created August 28, 2018 11:18
Auto Update stack from Internet
on mouseUp
put url "http://thisisanexampleurl.com/savedVersion.txt" into theVersion
if the currentVersion of this stack < theVersion then
put the effective filename of this stack into thePath
put url "http://thisisanexampleurl.com/newStack.livecode" into url ("binfile:" & thePath)
revert
end if
end mouseUp
@AndyPiddock
AndyPiddock / Check for program running.livecode
Created August 28, 2018 11:23
Check for program running - Windows
--Check for program running e.g. Notepad
on mouseUp
put empty into fld "myTaskList"
put shell ("TaskList") into fld "myTaskList"
if "notepad.exe" is among the tokens of fld "myTaskList" then
answer "Notepad is Running"
end if
end mouseUp
@AndyPiddock
AndyPiddock / MD5 Password Generator.livecode
Created August 28, 2018 14:50
MD5 Password Generator
--MD5 Password Generator
function hexDigest pvalue
put "" into tRes
put md5Digest(pValue) into tMD5
get binaryDecode("H*",tMD5,tRes)
return tRes
end hexDigest
@AndyPiddock
AndyPiddock / Get colour at pixel.livecode
Last active November 15, 2022 11:04
Gets the colour of a pixel at a x,y co-ordinate #colour #color
--Gets the colour of a pixel at a x,y co-ordinate
--This uses the mouscolor command.
on mouseUp
put PixelColor(500,500)
end mouseUp
function PixelColor x,y
put the screenMouseLoc into tSaveLoc
@AndyPiddock
AndyPiddock / SQLite database routines
Last active November 26, 2022 17:27
SQLite database routines #database,sqlite
--custom properties of stack
--cpAppPath : path to app
--cpDatabaseID : current active database connection number
--cpDataBaseName : name of database to access
on openCard
mobileOrientation
getAppPath
nameDataBase
@AndyPiddock
AndyPiddock / isBright.livecode
Last active November 29, 2022 11:38
Ensure that foreground and background color combinations provide sufficient contrast
function isBright r,g,b
local tbrightness
put (r * 299 + g * 587 + b * 114) / 1000 into tbrightness
if tbrightness > 125 then
return "no"
else
return "yes"
end if
end isBright