Am I missing something?

I keep getting an error saying "Can not make “first character of charSeq into a number.”
No where in my code do I have anything trying to set it into a number/integer. The only other code is properties defined above, none of which are set to numbers/integers. Am I missing something?

What I’m trying to do is get the charSeq variable and make a list of the characters, for example: “Hello” would become {“H”,“e”,“l”,“l”,“o”}

	if the contents of text field "charSeq" of window "main" is not equal to "" then
		set charSeq to the contents of text field "charSeq" of window "main"
		repeat with i in characters of charSeq
			set theList to theList + i as list
		end repeat
	end if
	display dialog theList

Also, this is my first time using the Repeat function, if anything is wrong or could be more efficient, I’m listening.

Hi Harry,

the operand + adds numeric values
the operand & concatenates strings, lists or records.

But for your purpose a repeat loop is not necessary,
characters of results a list of the characters of a string

	tell (get content of text field "charSeq" of window "main")
		if it is not "" then set charSeq to characters of it
	end tell

one cat, three ways to skin it

set theList to {}
set charSeq to "Hello"

--option 1
set theList to characters of charSeq

--option 2
repeat with aCharacter in characters of charSeq
	set end of theList to aCharacter
end repeat

--option 3
repeat with i from 1 to count characters of charSeq
	set end of theList to character i of charSeq
end repeat

Okay so there are more than 3 ways, but lets start there.

::blasted stefan :stuck_out_tongue: ::

Thank ya!

Note: aCharacter has to be dereferenced, otherwise the result is {item 1 of every character of “WhatEver”, item 2 of every character of “WhatEver”, .}

repeat with aCharacter in characters of charSeq
	set end of theList to contents of aCharacter
end repeat

I beg your pardon :wink:

Good call Stefan, forgot about that

And quit beating me to the punch all the time :smiley:

See also: List

Thanks for everyone’s help.

I got my application to work perfectly now. What I was making was a Key generating program. Where you decide what the outcome will be by providing a sequence (For example: “aaA#-##AA-#Aaa”). It will then pick a random capitalized letter for every “A”, lower case letter for every “a”, and so on. Work’s great!

Added a feature for multiple key generations and saving the key(s) you generated to a text file.