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.
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