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 / 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 / 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 / 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 / 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
if the platform is "android" then
set the fullscreenmode of this stack to "showAll"
mobileSetAllowedOrientations "portrait,portrait upside down"
end if
@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