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

Similar Threads
thread Thread Starter Forum Replies Last Post
Why so much Applescript? Dranix Mac Programming 25 May 2, 2014 01:05 AM
help with applescript andrewisgod Mac Programming 0 Apr 18, 2014 07:58 AM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Programming 0 Oct 28, 2013 11:38 PM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Applications and Mac App Store 0 Oct 28, 2013 11:32 PM
Help with an Applescript Theydonboi Mac Applications and Mac App Store 2 Nov 5, 2012 11:52 AM

Forum Jump

All times are GMT -5. The time now is 11:35 AM.

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

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