Understanding POSIX to read Paths

Hello,
I learning Applescript and have been using a couple of books. I am having trouble understanding why I get this error: Can’t get every character of alias “Applications HD:Users:boyd:Desktop:Illegallll/.rtf”. When I run the following script. I also try to change it to a POSIX path and get the same error. Any help would be greatly appreciated.


--Store the current TIDs. To be polite to other scripts.
set previousDelimiter to AppleScript's text item delimiters
set potentialName to choose file with prompt ("select your file") as text
set legalName to {}
set illegalCharacters to {".", ",", "/", ":"} --Whatever you want to eliminate.
--Now iterate through the characters checking them.
repeat with thisCharacter in the characters of potentialName --THIS IS THE ERROR LINE
	set thisCharacter to thisCharacter as text
	if thisCharacter is not in illegalCharacters then
		set the end of legalName to thisCharacter
	end if
end repeat
--Make sure that you set the TIDs before making the
--list of characters into a string.
set AppleScript's text item delimiters to ""
--Check the name's length.
if length of legalName is greater than 32 then
	set legalName to items 1 thru 32 of legalName as text
else
	set legalName to legalName as text
end if
--Restore the current TIDs. To be polite to other scripts.
set AppleScript's text item delimiters to previousDelimiter
return legalName



Hi,

. prompt as text coerces the literal string to text, not the result of the expression.
Use parentheses


.
set potentialName to (choose file with prompt "select your file") as text
.

Hi Stefan,

I wanted to thank you for your help. You have been very crucial to helping me progress in my understanding and I have greatly appreciated your knowledge and willingness to share this. Thanks again.