I’m working on it… I’ll at least get something that somebody else can clean up for you. My way of quasi random numbers will likely generate some repeats. Is that a problem?
Just to be clear, explain it to me like I’m stupid. 2 columns, how many in each? 50 each column for a total of 100 on the page? Oh, and keep in mind, it’s getting late here on the East Coast - if I don’t post back soon, check in the morning.
And slowing down the torrent of posts and e-mails will let slow fingers do more typing in Script Editor.
j
I have somthing that works, but it’s flawed and ugly. I haven’t tried printing the result, but it’s after midnight - so I’m done for now. Read the comments in the script that I hope somebody will beautify or replace with something better.
set numList to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
set theMult to ""
--this makes it easier to change the space between the two columns, although the second doesn't align because the problems are differing lengths. Didn't have time to sort this out. At least it works...
set theSpace to ""
repeat 50 times
set theSpace to theSpace & space
end repeat
set theSpace to theSpace
--Sorry about the monster line in here but I was generating 100 identical problems when I simplified it and it's getting late, so...
repeat 50 times--100 problems total
set theMult to theMult & (((((some item in numList) as string) & " x " & ((some item in numList) as string) & " = ") & theSpace & (((some item in numList) as string) & " x " & ((some item in numList) as string) & " = ")) & return & return)-- that's 12 pairs, did I set a shameful record?
end repeat
tell application "TextEdit"
activate
set myWindow to make new document
set name of front window to "Multiplication Problems"
set text of myWindow to theMult
--this will save the document
save myWindow
tell application "System Events" to keystroke "Multiplication Problems"
delay 1 - or it clicks too soon
tell application "System Events" to tell window 1 of process "TextEdit"
tell button "Save" of sheet 1
click
end tell
end tell
end tell
It’s officially Father’s Day - and my 3 1/2 year old daughter (that’s 3, not 13) has asked for a motorcycle and a tattoo!!! - so killsquad92, tell your parents I feel their pain.
I need some rest.
Oh, and this
should have been in the first post. Dude.
killsquad,
be so kind and read what you wrote above at the start of this thread - and then tell me: where have you written something about columns and multiplication problems. Sorry - I don’t have the time to guess what was meant with your second post (as English is not my native language it may be a little harder for me than for others and I am not interested in ‘winning a medal’ for decipher what you wrote.
My suggestion for your next posting … describe a little more detailed what’s your problem and you’ll probably have a solution faster
k. Here’s my attempt - I does mainly the same as capitalj’s script - but uses some spaces and a font with fixed widths to make the columns look nicer …
set theList to ""
repeat with n from 1 to 50
set theList to theList & (my randomInt(12) & " x " & my randomInt(12) & " = \t" & my randomInt(12) & " x " & my randomInt(12) & " =" & return)
end repeat
tell application "TextEdit"
make new document
set text of document 1 to theList
set font of text of document 1 to "Courier"
end tell
-- ... set title of the document + save dialog like capitalj's script, if you want this part ...
on randomInt(n)
set retVal to (((random number (n) as integer) + 1))
if retVal < 10 then return " " & retVal
return retVal as string
end randomInt
Edit: just noticed that the space (tab) between the columns got lost when I copy/pasted this to the thread - sorry - I’ve edited the script manually - now it should work as expected …
Give this a try:
property rowCount : 10
property columnCount : 2
property minNumber : 1
property maxNumber : 10
property timesSign : «data utxt00D7» as Unicode text
set usedEquations to {}
set displayList to {}
set text item delimiters to tab
repeat rowCount times
set rowList to {}
repeat columnCount times
repeat
tell {random number from minNumber to maxNumber, random number from minNumber to maxNumber} to ¬
if it is not in usedEquations or reverse of it is not in usedEquations then
set end of usedEquations to it
set end of rowList to (beginning as string) & space & timesSign & space & end & " ="
exit repeat
end if
end repeat
end repeat
set end of displayList to rowList as Unicode text
end repeat
set text item delimiters to return
set displayList to displayList as Unicode text
set text item delimiters to ""
tell application "TextEdit"
activate
set text of (make new document) to displayList
end tell
Column widths can be edited by simply changing the width of the tabs in the ruler in TextEdit.
I was going to clean up my ugly script, but I’m happy to see others have done it already. Back to Father’s Day.