Skip to content

Instantly share code, notes, and snippets.

@AndyPiddock
AndyPiddock / getScriptOfSE.lc
Last active November 24, 2023 15:52
Get script of the current tab of the Script Editor
put the title of stack "revNewScriptEditor 1" into tObject
set the itemDel to "-"
delete item -1 of tObject
put the script of tObject
@AndyPiddock
AndyPiddock / checkfornumbersinfield.lc
Created February 22, 2023 15:44
Check that only numbers entered in field
on keyDown tkey
if tKey is not a number then
exit keyDown
else
pass keyDown
end if
end keyDown
@AndyPiddock
AndyPiddock / exitreturninfield.lc
Created February 22, 2023 15:42
Ignore returns in field
on returnInField
exit to top
end returnInField
@AndyPiddock
AndyPiddock / countdowntimer.livecode
Created January 14, 2023 14:38
Countdown Timer
local tCountdown
function countdown pPeriod, pAction
set the numberFormat to "00."
if pAction = "Start" then
put pPeriod into tCountdown
repeat while tCountdown > -1
put tCountdown div 60 & ":" & (tCountdown mod 60) into field "timer"
wait 1 second with messages
subtract 1 from tCountdown
@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
if the platform is "android" then
set the fullscreenmode of this stack to "showAll"
mobileSetAllowedOrientations "portrait,portrait upside down"
end if
@AndyPiddock
AndyPiddock / Tsnet Github Gists api.livecode
Last active November 30, 2022 14:25
Tsnet Github Gists api access using token #github #gist #api #tsnet #livecode
on mouseUp
local tRequestHeaders, tResponseHeaders, tResult, tBytes, tData
local tSettings, tCharNo, tUrl
put "https://api.github.com/gists" into tUrl
-- Build headers for HTTP request
put "Accept: application/vnd.github+json" & cr into tRequestHeaders
put "User-Agent: LC App" & cr after tRequestHeaders
@AndyPiddock
AndyPiddock / Colorize the script in a field.livecode
Last active November 30, 2022 14:24
colorize the script in a field to the SE current colors
---colorize the script in a field to the SE current colors
put the num of chars of fld "myField" of this stack into tEndChar
dispatch "revSEColorizeField" to stack "revseutilities" with the long id of field "myField" of this stack, 1, tEndChar
@AndyPiddock
AndyPiddock / Escape returns and quotes.livecode
Last active November 30, 2022 14:23
Escape returns and quotes in a string #escape,json,post
--escape returns and quotes
replace return with "\n" in myStringe
replace quote with "\" & quote in myString
@AndyPiddock
AndyPiddock / Unix timestamp to datetime items.livecode
Last active November 30, 2022 14:20
Unix timestamp to date/time items
function ConvDate pDate
convert pDate to dateitems
put item 1 of pDate into tDateY
put format("%02d",item 2 of pDate) into tDateM
put format("%02d",item 3 of pDate) into tDateD
put format("%02d",item 4 of pDate) into tDateH
put format("%02d",item 5 of pDate) into tDateMin
put format("%02d",item 6 of pDate) into tDateS