Friday, December 15, 2017

#1 2002-02-22 09:09:24 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Newbie requiring help...

Thanks for reading this!

I'm making an installer using StuffitInstallerMaker 7.1.1. part of the installation requires that i modify text within a text file (i'm installing a modification for Deus Ex, and it requires you to change 3 lines of text within deusex.ini - a text file). i see from apple's website that neither textedit nor simpletext are scriptable. i'd like to write a hybrid os9/x script that would be able to change these lines of text within the file. how can i do that without requiring the user to install additional software? thanks a ton...

-blobbo


One mans trash is another mans treasure

Offline

 

#2 2002-02-22 01:51:59 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

If by "textedit" you mean "Tex-Edit Plus" then there is a misunderstanding somewhere. It is THE scriptable word processor par exellence.


One mans trash is another mans treasure

Offline

 

#3 2002-02-22 02:26:30 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

If by "textedit" you mean "Tex-Edit Plus" then there is a misunderstanding somewhere. It is THE scriptable word processor par exellence.


You're both right. TextEdit is the Teachtext of OSX. Tex-Edit Plus rocks. See below link for more on the later.

--tet


One mans trash is another mans treasure

Offline

 

#4 2002-02-22 02:45:12 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

You're both right. TextEdit is the Teachtext of OSX. Tex-Edit Plus rocks. See below link for more on the later.


Is OS X's TextEdit scriptable? I'm in 9 right now and don't feel like booting over to find out.

I also recently acquired Tex-Edit Plus, at Andreas' prompting.


One mans trash is another mans treasure

Offline

 

#5 2002-02-22 04:31:26 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

Is OS X's TextEdit scriptable? I'm in 9 right now and don't feel like booting over to find out.


It is, to my surprise. (I'm not sure why I thought it wasn't--did it not used to be?)
Anyway, check out the below link for some examples.

--tet


One mans trash is another mans treasure

Offline

 

#6 2002-02-22 04:50:07 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

In the interests of truth and justice I just want to add that I was introduced, and not all that long ago, to Tex-Edit Plus by Marc Myers, who uses it beautifully in some of his own scripts.


One mans trash is another mans treasure

Offline

 

#7 2002-02-23 06:00:24 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

um, can someone help me with my initial question? i'll try out textedit plus for sure smile. but i really need help with the initial post...


One mans trash is another mans treasure

Offline

 

#8 2002-02-25 01:54:45 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

um, can someone help me with my initial question? i'll try out textedit plus for sure smile. but i really need help with the initial post...


Well, since it turns out Textedit is scriptable, you could use that to edit text on the end-user's machine.

Or, you could do it w/ just AS. The following example is a script from Marc Myers. It reads chunks to the end of the file, which is not really what you want to do, but it'll give  you a start. See the File Read/Write section of the Standard Additions dictionary for more info.

Applescript:

set theFile to (choose file)
set fileID to (open for access theFile)

try
    repeat
        set theText to (read theFile before return)
        log theText
    end repeat
on error m number n
    close access fileID
    if n is not -39 then -- if so, then EOF
        display dialog (n as text) & return & m
    end if
end try

--tet


One mans trash is another mans treasure

Offline

 

#9 2002-02-27 08:29:25 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

Marc, if you read this...

Fascinating piece of code. I sense there's something to learn here. What did you write it for? What does it do - or should I ask rather what one does with it - with the line after line appearing in the log?

An explanation from you would be very welcome.


One mans trash is another mans treasure

Offline

 

#10 2002-02-28 04:20:43 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

Fascinating piece of code. I sense there's something to learn here. What did you write it for? What does it do - or should I ask rather what one does with it - with the line after line appearing in the log?


See below link for the original post (see rest of the thread for the context.)

--tet


One mans trash is another mans treasure

Offline

 

#11 2002-02-28 05:59:58 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

Aha! Not as esoteric as I'd thought it might be - actually pretty simple - but, of course, nice to-the-point code from The Man in Green!

Thank you, tet.


One mans trash is another mans treasure

Offline

 

#12 2002-03-08 11:25:29 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Newbie requiring help...

like this:

Applescript:

-- set this to the start of where you want to change things (one before the first character to change)
set startOffset to 10
-- set this to the end (one after the last char to change)
set endOffset to 15
-- set this to what to change it to
set newText to "blah blah" & return & "more text"
-- get file to change
set f to choose file
-- read file
set df to open for access f
try
set t to read df
on error m number n
close access df
error m number n
end
close access df
-- change text
set newT text 1 through startOffset of t set newT to newT & newText
set newT to newT & text endOffset of t
-- write changes
set df to open for access f with write permission
try
set t to write newT to df
on error m number n
close access df
error m number n
end
close access df
-- done

i havn't tested it, sorry i don't have time. email me if it doesn't work - jail


One mans trash is another mans treasure

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)