text
stringlengths
0
15.7k
source
stringlengths
6
112
set result to text oStart thru oEnd of theText
LIB_Text.applescript
end textBetween
LIB_Text.applescript
to textBetween_old(theText, startString, endString)
LIB_Text.applescript
set AppleScript's text item delimiters to startString
LIB_Text.applescript
set theString to item 2 of text items of theText
LIB_Text.applescript
set theString to item 1 of text items of theString
LIB_Text.applescript
theString
LIB_Text.applescript
end textBetween_old
LIB_Text.applescript
on lastOffset(theString, theCharacter)
LIB_Text.applescript
set strRev to (reverse of characters of theString) as text
LIB_Text.applescript
set s to (length of theString) - (offset of theCharacter in strRev) + 1
LIB_Text.applescript
on lastOffset2(theText, char)
LIB_Text.applescript
set len to count of theText
LIB_Text.applescript
set reversed to reverse of characters of theText as string
LIB_Text.applescript
end lastOffset2
LIB_Text.applescript
on lstripString(theText, trimString)
LIB_Text.applescript
repeat while theText begins with the trimString
LIB_Text.applescript
set theText to characters (x + 1) thru -1 of theText as text
LIB_Text.applescript
end lstripString
LIB_Text.applescript
on stripString(theText, trimString)
LIB_Text.applescript
set theText to lstripString(theText, trimString)
LIB_Text.applescript
set theText to rstripString(theText, trimString)
LIB_Text.applescript
end stripString
LIB_Text.applescript
on NthOffset(theString, matchString, occurrence, startPos)
LIB_Text.applescript
if occurrence < 0 then
LIB_Text.applescript
set theString to text 1 thru startPos of theString
LIB_Text.applescript
set startPos to 1
LIB_Text.applescript
set str to (reverse of characters of theString) as text
LIB_Text.applescript
set matchString to (reverse of characters of matchString) as text
LIB_Text.applescript
set str to theString
LIB_Text.applescript
if startPos < 0 then
LIB_Text.applescript
set pos to (length of theString) + startPos + 1
LIB_Text.applescript
set pos to startPos
LIB_Text.applescript
repeat with n from 1 to my abs(occurrence)
LIB_Text.applescript
set strCur to text pos thru -1 of str
LIB_Text.applescript
set posCur to offset of matchString in strCur
LIB_Text.applescript
if posCur = 0 then return 0
LIB_Text.applescript
set pos to pos + posCur
LIB_Text.applescript
set pos to pos - 1
LIB_Text.applescript
set posFinal to (length of theString) - pos + 1
LIB_Text.applescript
set posFinal to pos
LIB_Text.applescript
return posFinal
LIB_Text.applescript
end NthOffset
LIB_Text.applescript
on trim_paragraphs(this_text, trim_chars, trim_indicator)
LIB_Text.applescript
set the paragraph_list to every paragraph of this_text
LIB_Text.applescript
repeat with i from 1 to the count of paragraphs of this_text
LIB_Text.applescript
set this_paragraph to item i of the paragraph_list
LIB_Text.applescript
set item i of the paragraph_list to trim_line(this_paragraph, trim_chars, trim_indicator)
LIB_Text.applescript
set this_text to the paragraph_list as string
LIB_Text.applescript
end trim_paragraphs
LIB_Text.applescript
to stripChar of char from someText
LIB_Text.applescript
set charToRemove to char
LIB_Text.applescript
set AppleScript's text item delimiters to charToRemove
LIB_Text.applescript
set TextItems to someText's text items
LIB_Text.applescript
set a to 1
LIB_Text.applescript
set b to (count TextItems)
LIB_Text.applescript
repeat while (a < b) and ((count item a of TextItems) is 0)
LIB_Text.applescript
set a to a + 1
LIB_Text.applescript
repeat while (b > a) and ((count item b of TextItems) is 0)
LIB_Text.applescript
set b to b - 1
LIB_Text.applescript
set strippedText to text from text item a to text item b of someText
LIB_Text.applescript
strippedText
LIB_Text.applescript
end stripChar
LIB_Text.applescript
on binarySearch:aValue withValues:values
asbs.applescript
set res to false
asbs.applescript
set valuesLength to count values
asbs.applescript
set midIndex to valuesLength div 2
asbs.applescript
if midIndex = 0 then
asbs.applescript
if aValue = (first item of values) then
asbs.applescript
set res to true
asbs.applescript
set midValue to item midIndex of values
asbs.applescript
log "value is " & values
asbs.applescript
log "values length is " & valuesLength
asbs.applescript
log "mid index is " & midIndex
asbs.applescript
log "mid vlaue is " & midValue
asbs.applescript
if midValue > aValue then
asbs.applescript
set res to (my binarySearch:aValue withValues:(items 1 thru midIndex of values))
asbs.applescript
else if midValue < aValue then
asbs.applescript
set res to (my binarySearch:aValue withValues:(items (midIndex + 1) thru valuesLength of values))
asbs.applescript
else if midValue = aValue then
asbs.applescript
end binarySearch:withValues:
asbs.applescript
set values to {1, 2, 3, 6, 7, 9, 11, 13, 15}
asbs.applescript
repeat with i from 1 to (end of values)
asbs.applescript
set searchValue to i
asbs.applescript
log "Search for " & i
asbs.applescript
set result to (my binarySearch:searchValue withValues:values)
asbs.applescript
log "The search value[" & searchValue & "] is found in " & values & "."
asbs.applescript
log searchValue & " not found."
asbs.applescript
do shell script "/usr/local/bin/tag --set zero " & (POSIX path of theItem)
Remove_all_Tags.applescript
do shell script "/usr/local/bin/tag --remove zero " & (POSIX path of theItem)
Remove_all_Tags.applescript
set workspaceProjects to projects of active workspace document
SwapToSpec.applescript
if (count of workspaceProjects) > 0 then
SwapToSpec.applescript
set currentFileName to name of text document 1 whose name ends with (word -1 of (get name of window 1))
SwapToSpec.applescript
if (length of currentFileName) > 0 then
SwapToSpec.applescript
set filenameToFind to (characters 1 thru (prefixLen - 4) of filePrefix) as string
SwapToSpec.applescript
set filenameToFind to filePrefix & "Spec"
SwapToSpec.applescript
set objCppFilenameToFind to filenameToFind & ".mm"
SwapToSpec.applescript
set objCFilenameToFind to filenameToFind & ".m"
SwapToSpec.applescript
set projectDirs to ""
SwapToSpec.applescript
repeat with currentProject in workspaceProjects
SwapToSpec.applescript