RTF format would be great but Simple-text too
I just need a script that reverse text inside a file
whatever is writing inside it not matter
Its actually for hebrew in flash
in flash i cant write good so i need to right in reverse and its hard…
this why i want a script that reverse it and ill paste the text inside flash =)
Hmmm… Then you maybe better interested in writing a JSFL command (accessible from your “Commands” menu inside Flash 7, and much quicker!):
Ôªø
d=fl.getDocumentDOM();
if (! d) {
alert('Please, open a document before running this command!');
} else {
doIt();
}
function doIt(){
s = d.selection;
if (s.length == 0){
if (d.getTextString() == undefined) {
alert('Select some text before running this command!');
} else {
FC();
}
return;
}
for (i=0;i<s.length;i++){
d.selectNone();
d.selection = [s[i]];
rev();
}
d.selection = s;
}
function rev(){
x = d.getTextString().split('').reverse().join('');
d.setTextString(x);
}
Make a new JSFL script window in Flash (“New…” menu), copy-paste this code, save in the dir “~/Application Support/Macromedia/Flash MX 2004/en/Configuration/Commands”. Write your text in the stage. Select the text field. Choose your new jsfl script in the “Commands” menu, and you are done.
If you own, though, Flash 6, perhaps you can write your text in TextEdit, then run something as:
tell application "TextEdit" to set x to text of document 1
set the clipboard to (reverse of (x's text items) as text)
And this will place your reversed text in the clipboard, ready to paste in Flash. :rolleyes:
NOT SURE, though, if these methods will support Unicode text…
This was my “NOT SURE”. This is out of my scope, but one of these rough tricks could work if you use only two-byte Unicode:
tell application "TextEdit"
set x to text of document 1
end tell
set rev to "" as Unicode text
repeat with i from 1 to count x
set rev to rev & text item -i of x
end repeat
set the clipboard to rev
tell application "TextEdit"
set x to text of document 1
end tell
set x to Unicode2Raw(x)
set raw to {}
repeat with i from 1 to count x by 4
set raw's end to text -i thru -(i + 3) of x
end repeat
run script "set the clipboard to «data utxt" & raw & "»"
to Unicode2Raw(x)
set x to x as Unicode text
set ind to -((x's length) * 4) - 18
{{kaka:x}}
result as string as C string
try
result * 5
on error msg
return text ind thru -19 of msg
end try
end Unicode2Raw
Hi man Thats Great,
I thought it will be easy for experience guy like you =)
anyway i want this script to run when I’ll drop TextEdit file on it…
and then open the file i dropped in TextEdit,
And the Script will convert the text to my Clipboard!
Oh and about the Flash JS its running great,
I just want you to make little modification…
when I select a block of that It reverse the order of the lines =)
Make the first line last and so on…
can you set it right? or Its to much complicated?!
oh and if i select all the text inside the text block… i get some error about something inside the FLJS line 1, So i need to select to block him self to prevent it
JSFL, very easy. Substitute the function “rev” with:
function rev(){
x = d.getTextString().split('').reverse().join('');
x = x.split('r').reverse().join('r'); // same mechanism ;-)
d.setTextString(x);
}
AppleScript code, simply add a “open” handler:
on open listOfFiles
repeat with i in listOfFiles
tell application "TextEdit"
open i
set x to text of document 1
close document 1
end tell
set rev to "" as Unicode text
repeat with i from 1 to count x
set rev to rev & text item -i of x
end repeat
set the clipboard to rev
beep 2
end repeat
end open