Every time I try to run a script, the Editor launches. Why?

There are different ways to save a script, if you save it as an “Application” it will not open in the Script Editor when you doublle click it. If your script is saved as “Script, or Text” it will open in the Script Editor when double clicked.

Yeah, I figured that part out Greg. But if I save it as an application will it always require an “okay” prompt to run it? I would like to be able to just double-click the script and have the script run without any other prompts. (I haven’t worked with Applescript in several years and don’t remember it working this way.)

When you save a script as an “Application” there’s a check box that says “Startup Screen” if that box has a check mark in it, you will see the “Press RUN to blah blah…” dialog each time the script (application) is launched. If you save your script as “Run Only” you will not be able to edit it in the Script Editor.

I am having a difficult time wrapping my brain around what should be an easy routine.

If I have a list, ex.:
{“123”,“AB”,“456”} ← simplified for example purposes only

I would like to have output as follows:
{“1A4”,“1A5”,“1A6”,“1B4”,“1B5”,“1B6”,“2A4”,“2A5” … “3B6”}

I know this can be done with a recursive routine, but it’s hurting my brain :cry:

Thanks in advance,
Brad Bumgarner, CTA

[edit: I don’t know why, but this post seems to be added to the end of another topic, even though I created a new topic. I tried this 3 times to make sure I wasn’t doing something incorrectly. I even quit Safari and relaunched – same result.]

This might work.

set a to {"123", "AB", "456"}
set b to {}

set block1 to characters of item 1 of a
set block2 to characters of item 2 of a
set block3 to characters of item 3 of a

repeat with x in block1
	repeat with y in block2
		repeat with z in block3
			copy (x & y & z) to end of b
		end repeat
	end repeat
end repeat


--> {"1A4", "1A5", "1A6", "1B4", "1B5", "1B6", "2A4", "2A5", "2A6", "2B4", "2B5", "2B6", "3A4", "3A5", "3A6", "3B4", "3B5", "3B6"}

– Rob


Thanks for the reply. I had this important bit of info in one attempt to post to list, but it didn’t make into the last post:

The number of items in the list will change. There could be anywhere from 3 or 4 items up to 10 or more items. That is why I was looking at doing this with a recursive routine. My apologies for leaving that bit out, but I typed the question a few times trying to get this to post properly.

Brad Bumgarner, CTA

:shock: I see. :wink:

I don’t have any suggestions at this time but if I find time, I’ll try to work on a more flexible routine. Hopefully someone else will offer a solution since I’m going to be rather busy for the next few days.

Good luck!

– Rob


I got an idea for this, but still working out the kinks in my head. You know how when you change a decimal number to binary you get a series of 1s and 0s? Maybe you can do this to get combinations of characters of strings from the list. For instance, the list:


has 3 items and the longest string has 3 chars. The first item of the combination is:


notice that the last number in your number system would be:

333 – actually the numbers would go from 000 to 222 in this number system so add 1 in the folloowing

but there is no such item in your combination list. So you have to fill the strings that have less than 3 chars. You new list might be like this:

{{1,2,3},{A,B,missing value},{4,5,6}}

I left out the quote marks on the strings for easy typing. Now when you go through your number system you repeat 3 to the third power (3^3). In the next repeat you repeat through the string and get those items from each list. For instance say the outer loop is on the number “221”. Repeat through this and get that item from the sublist. Remember the missing value ones. these need to be discarded from the new list.



If you want you can look it this rough draft with hardly any error checking. I ended up using the strings directly instead of making the list of lists. Note that the base string needs to have the same length of the main list. If you want a quick algorithm, I can jot down the main points:

– main
set base_chars to “0123456789ABCDEF”
set the_list to {“123”, “AB”, “456”}
set list_count to (count the_list)
– get the base
set the_base to 0
repeat with this_item in the_list
set this_length to (length of this_item)
if this_length > the_base then
set the_base to this_length
end if
end repeat
set combo_count to (the_base ^ list_count) as integer
set high_decimal to combo_count - 1
– make list of combinations
set combo_list to {}
repeat with i from 0 to high_decimal
– convert to i to the_base
set base_string to DecToBase(i, the_base, list_count)
– get the combo that this base_string represents
set this_combo to “”
set the_flag to true
repeat with j from 1 to list_count
set this_item to (item j of the_list)
set this_char to (character j of base_string)
– get the index of the character
set char_index to (offset of this_char in base_chars) – 1 to 16
set combo_item to (item char_index of this_item)
set this_combo to this_combo & combo_item
on error
set the_flag to false
exit repeat
end try
end repeat
if the_flag then
set end of combo_list to this_combo
end if
end repeat
{combo_list, (count combo_list) = 3 * 2 * 3}
---------- subroutine
– returns the base string of a decimal number
on DecToBase(dec_num, the_base, num_places)
if the_base > 16 then error “base too high”
set base_chars to “0123456789ABCDEF”
set the_zeros to “000000000000000”
set base_string to “”
repeat until dec_num < the_base
set temp_num to (dec_num mod the_base)
set base_string to (character (temp_num + 1) of base_chars) & base_string
set dec_num to dec_num div the_base
end repeat
set base_string to (character (dec_num + 1) of base_chars) & base_string
set base_string_mod to text -(num_places) thru -1 of (the_zeros & base_string)
return base_string_mod
end DecToBase

If you go through it think of errors that may arise. I hardly did that.


on gather_list(the_list)

set the_result to {}

repeat with each_item in the_list

copy each_item’s characters to the end of the_result

end repeat

return the_result

end gather_list

on recurse(the_list, the_base)

the_base as string
on error
set the_base to “”
end try

set the_results to {}

repeat with each_item in item 1 of the_list
if the count of the_list is 1 then
copy the_base & each_item to the end of the_results
recurse(the rest of the_list, the_base & each_item)
copy the result to the end of the_results – I mean append… may make lists of lists…
end if
end repeat

return the_results

end recurse

set the_list to gather_list({“ABC”,“123”,“XYZ”})
recurse(the_list, “”)

I think the recursion strategy may be a red herring. Try the following:

[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thanks all, for the responses. I will look at each of your ideas today, time permitting. For some reason, I keep running into a brick wall with this one. :?

I’ll let you know how they worked.

Thanks again,
Brad Bumgarner, CTA


Where were you guys before I started on my idea! :slight_smile: It was a nice puzzle anyway.


I KNEW THIS COULD BE DONE! Thanks Kel, Mooresan and Steve :smiley: You all did better than I did.

Steve, your code is straight-forward, concise and I’m kicking myself for not thinking of it myself :wink:

Now, I’ll be able to continue with my project.

Thanks again,
Brad Bumgarner, CTA


I was thinking of this strategy and decided to try a new aproach. Instead of using the base, I created an index list (like a counter). It’s slightly faster than the other scripts although it’s longer. It wasn’t texted with differnt lists and also eliminated the max string lengths.

set the_list to {“123”, “AB”, “456”}
set tick1 to the ticks
set list_count to (count the_list)
set index_list to {}
set the_lengths to {}
repeat with this_item in the_list
set item_length to (length of this_item)
set end of the_lengths to item_length
set end of index_list to 1
end repeat
copy index_list to index_list_copy
set combo_list to {}
– get this combination
set this_string to “”
set incr_next to true
repeat with i from 1 to list_count
set this_item to item i of the_list
set this_index to item i of index_list
set this_char to item this_index of this_item
set this_string to this_string & this_char
– incr index_list
if incr_next then
set this_length to item i of the_lengths
if this_index < this_length then
set item i of index_list to this_index + 1
set incr_next to false
set item i of index_list to 1
end if
end if
end repeat
set end of combo_list to this_string
if index_list = index_list_copy then exit repeat
end repeat
set tick2 to the ticks
display dialog (tick2 - tick1)

Note that it can be made even faster with the ‘a reference to’ operator, but this method needs to be global if used throughout a script.