Pages

Affichage des articles dont le libellé est AppleScript : Text. Afficher tous les articles
Affichage des articles dont le libellé est AppleScript : Text. Afficher tous les articles

29 oct. 2011

Script To Markup Code

Crée le code des liens  de ce blog qui permettent d'ouvrir le script sur le Mac de l'utilisateur.

-- ASCII character (34) -- %22 -- quote
-- ASCII character (32) -- %20 -- espace
-- ASCII character (9) -- %09 -- tabulation
-- ASCII character (10) -- %0A --  retour chariot
-- ASCII character (58) -- %3A -- colon 
-- ASCII character (60) --  "%3C" -- <
-- ASCII character (62) --  %3E -- >

set charList to {ASCII character (32), ASCII character (34), ASCII character (9), ASCII character (58), ASCII character (62), ASCII character (60)}
set temp to the clipboard as text
set newText to ""

-- Codage des quote, espace, tabulation, colon, < et >
repeat with theChar in temp
if theChar is in charList then
set newText to newText & encodeChar(theChar)
else
set newText to newText & theChar
end if
end repeat

-- Codage des retour chariot
set theParagraphs to every paragraph of newText
set newContents to ""
repeat with thisParagraph in theParagraphs
set thisParagraph to thisParagraph & "%0A" as string
set newContents to newContents & thisParagraph as string
end repeat

-- Ecriture du lien HTML cliquable dans le presse-papiers

on encodeChar(this_char)
set the ASCII_num to (the ASCII number this_char)
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
set x to item ((ASCII_num div 16) + 1) of the hex_list
set y to item ((ASCII_num mod 16) + 1) of the hex_list
return ("%" & x & y) as string
end encodeChar

2 juin 2008

Multiple find replace

on nFindReplace(theText, string1, string2) -- multiple search replace
repeat with i from 1 to the length of my string1
set AppleScript's text item delimiters to character i of string1
set theList to text items of theText
set AppleScript's text item delimiters to character i of string2
set theText to theList as text
end repeat
set AppleScript's text item delimiters to ""
return theText
end nFindReplace

>>Ouvrir le script dans l'éditeur

Find replace

on findReplace(theString, oldChar, newChar) -- search replace
set AppleScript's text item delimiters to oldChar
set theList to text items of theString
set AppleScript's text item delimiters to newChar
set theString to theList as text
set AppleScript's text item delimiters to ""
return theString
end findReplace

>>Ouvrir le script dans l'éditeur