…that will probably take you guys half a second to solve (but I’m stumped):
How do I grab the first letter of a word that is input?
Here’s the deal: I’m trying to make a nice server login script for our students, so that when they run the script, it asks them for their network username, then their network password, then it logs them onto the (Win NT, blah) server and opens their personal folder.
The folders are on the server sorted by the first letter of their last name: all the As are in the ‘a’ folder, Bs in ‘b’, etc.
The login command is simple to type into the Connect to Server dialong (afp://xxx.xxx.xxx.xxx/Users/s/smith).
So I want this to, after they input their username, grab the first letter of their last name (which is the first letter of their network username), then add that to the login command. If I can just grab that first letter of their username, I can plug it into that command.
Here’s what I have so far:
tell application "Finder"
activate
display dialog "Input your network username" default answer "" buttons {"Cancel", "OK"} default button 2
set theName to result
set theLetter to first letter of result
end tell
That’s just to test out what comes back as the result, but…it won’t even compile. I get the oh-so-helpful error of “Expected class name but found identifier.”
I tried changing the “set theLetter to first letter of result” to “set theLetter to first character of result”; it compiles fine, but when I run it with the Result pane open, I get “Can’t get character 1 of {text returned:“smith”, button returned:“OK”}.”
Any advice?