Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 11, 2008, 04:46 PM   #1
littlevish
macrumors member
 
Join Date: Oct 2007
AppleScript help

I'm coding a sports trivia homebrew game in Lua for the PSP. (not important)

I have made an AppleScript application to make it quicker for me to insert questions. I need to know if it's possible to insert line breaks into the file I'm writing to, so that the code does not get all jumbled up when I open the file later.

Code:
--Trivia Question Maker

display dialog "Question Table" default answer " "
set tableInfo to result
set table to text returned of tableInfo

display dialog "Question Number" default answer " "
set numInfo to result
set num to text returned of numInfo

display dialog "Enter Question" default answer " "
set questionInfo to result
set question to text returned of questionInfo

display dialog "Choice A" default answer " "
set aInfo to result
set choiceA to text returned of aInfo

display dialog "Choice B" default answer " "
set bInfo to result
set choiceB to text returned of bInfo

display dialog "Choice C" default answer " "
set cInfo to result
set choiceC to text returned of cInfo

display dialog "Choice D" default answer " "
set dInfo to result
set choiceD to text returned of dInfo

display dialog "Correct Answer (1,2,3,4)" default answer " "
set correctInfo to result
set correct to text returned of correctInfo

display dialog "Hint" default answer " "
set hintInfo to result
set hint to text returned of hintInfo

display dialog "Correct Message" default answer " "
set correctMessageInfo to result
set correctMessage to text returned of correctMessageInfo

display dialog "Wrong Message" default answer " "
set wrongMessageInfo to result
set wrongMessage to text returned of wrongMessageInfo

set finalQuestion to table & "[" & num & "] = {question=\"" & question & "\", A=\"" & choiceA & "\", B=\"" & choiceB & "\", C=\"" & choiceC & "\", D=\"" & choiceD & "\", correct=" & correct & ", hint=\"" & hint & "\", correctMessage=\"" & correctMessage & "\", wrongMessage = \"" & wrongMessage & "\"}"
set theFile to (choose file with prompt "Select a file to write the question to:")
open for access theFile with write permission
write finalQuestion to theFile starting at eof
close access theFile
littlevish is offline   0 Reply With Quote
Old Mar 11, 2008, 05:02 PM   #2
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Use & "\r" or & "\n" when building your strings to insert returns or linefeeds, respectively.
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote
Old Mar 11, 2008, 06:16 PM   #3
littlevish
Thread Starter
macrumors member
 
Join Date: Oct 2007
Ah, thanks.

I had tried that before but was missing the quotes.
littlevish is offline   0 Reply With Quote
Old Mar 12, 2008, 03:12 AM   #4
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Cool, you might want to have a look at AppleScript Studio (installed with Xcode tools), you could put all those form fields on a single page to make it faster, easier, and prettier to enter the info, and make it easier to modify later on.
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Handling Duplicate AppleScripts the Otter Mac Programming 1 Dec 22, 2010 05:53 AM
Applescript NOOB Revolume Mac Programming 2 Dec 1, 2010 08:06 AM
help with excel for mac 2008 damiang72 Mac Applications and Mac App Store 0 Nov 14, 2010 06:19 AM
AppleScript Help krohde Mac Help/Tips 2 Mar 20, 2003 05:06 PM
AppleScript help cleo General Mac Discussion 0 Apr 10, 2002 08:21 PM


All times are GMT -5. The time now is 10:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC