How can I add the contents of a text field to another text field? Say, for example I have a text field that says “Jones.” It’s name is "lastNameText. How can I add whatever is in the field to another text field, which we’ll call “outputText” but still keep whatever in in there before I added the text. I only know the “set the contents of textfield…” command. Also, I read something about if I set the contents of a text field to a variable, and then set the contents to what I want, with the variable sandwiched between ‘&’ it will at the contents. Any help would be appreciated!
Is this what you need?
set outputText to "Roger"
set lastNameText to "Jones"
set outputText to outputText & " " & lastNameText
– Rob
on clicked theObject
tell window "main"
set the contents of text field "BookFirst" to BookFirst
set the contents of text field "BookLast" to BookLast
set the contents of text field "BookTitle" to BookTitle
set the contents of text field "BookCity" to BookCity
set the contents of text field "BookPublisher" to BookPublisher
set the contents of text field "BookYear" to BookYear
set the contents of text field "BookOutput" to BookFirst & ", " & BookLast & ". " & BookTitle & ". " & BookCity & ": " & BookPublisher & ", " & BookYear & "."
end tell
end clicked
This is what I’ve got. It says I need to define the variables. You see what I’m trying to do, set whatever’s in the field to a variable. How can I do this? Any other visible problems, I’d be happy to know. Thanks.
Ah, the old “AppleScript Studio question in the wrong forum” trick! I can’t help you with Studio stuff.
– Rob
Oops! :oops: Sorry about that. Anyways, anyone who can help me, please do!
Is this what you mean?
on clicked theObject
tell window "main"
set BookFirst to contents of text field "BookFirst"
set BookLast to contents of text field "BookLast"
set BookTitle to contents of text field "BookTitle"
set BookCity to contents of text field "BookCity"
set BookPublisher to contents of text field "BookPublisher"
set BookYear to contents of text field "BookYear"
set contents of text field "BookOutput" to BookFirst & ", " & BookLast & ".? " & BookTitle & ".? " & BookCity & ":? " & BookPublisher & ", " & BookYear & "."
end tell
end clicked
Jon
Nope, there’s something wrong with that. Here’s what I’ve got:
on clicked theObject
if name of theObject is "BookGenerate" then
tell window "book"
set BookFirst to contents of text field "BookFirstName"
set BookLast to contents of text field "BookLast"
set BookTitle to contents of text field "BookTitle"
set BookCity to contents of text field "BookCity"
set BookPublisher to contents of text field "BookPublisher"
set BookYear to contents of text field "BookYear"
set the contents of text field "BookOutput" to BookFirst & ", " & BookLast & ". " & BookTitle & ". " & BookCity & ": " & BookPublisher & ", " & BookYear & "."
end tell
end if
end clicked
Notive I’ve changetd the window name, it’s actially called “book.” What I’m trying to do is put together a bibliography formatter. It’s an “NSReciever…” type error, the number after it is 4 (1), if that’s any help. Thanks for anyone’s help!