Skip to content

Instantly share code, notes, and snippets.

@AndyPiddock
AndyPiddock / get the path and file name.livecode
Last active November 30, 2022 11:47
LiveCode: get the path and file name of the running stack
--To get the path and file name
--the effective fileName of this stack
--To get just the path this works...
set the itemDelimiter to "/"
put (item 1 to -2 of the effective fileName of this stack) & "/" into tMyPath
@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 / 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 / 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 / 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 / Check for Long mouseDown.livecode
Last active December 2, 2022 10:24
Check for Long mouseDown
--Long Press
on mouseDown
put the ticks into tStart
wait until the mouse is up
if the ticks - tStart < 20 then answer "Short Press"
else answer "Long Press"
end mouseDown
@AndyPiddock
AndyPiddock / Countdown Timer.livecode
Last active November 30, 2022 11:04
Countdown Timer
--general timer routine
--start button
global gStartSeconds
global gPauseSeconds
on mouseUp
--calculate time duration in Seconds
put 60*60 into tFactor
--convert to seconds, truncate to whole number
put trunc(fld "timeDuration" * tFactor) into tDuration
@AndyPiddock
AndyPiddock / Open CD Tray.livecode
Last active November 30, 2022 11:04
Open CD Tray using vbScript
--Open CD Tray using vbScript
--Place a button.
--Add this to the mouseUp
on mouseUp
do the cOpenTray of me as "vbScript"
end mouseUp
--Create a Custom Property for the button named cOpenTray
@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 / Get Computer name.livecode
Last active November 30, 2022 12:14
Get Computer name
--OSX (and possibly linux distros):
put shell("echo $HOSTNAME")
--Windows:
put $COMPUTERNAME