Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

littlevish

macrumors member
Original poster
Oct 18, 2007
92
0
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
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.