Well, on a mouseUp, you are calling uppercase, and passing only your 
reference (me), but uppercase really takes two parameters, so you're 
effectively passing in nothing.

However, then you set it to the value of member "userData", so that gets 
around that problem (although a little backwards).

Also I note that you have a handler called upperCase and ALSO a property 
called uppercase.  Properties are private storage variables, and all you'll 
accomplish here is a name conflict.  I would suggest dropping the 'property 
Uppercase' as you're not using it, and if you do need it and just didn't 
include that info, then change the name.

At any rate, as a quick test, if you make UpperCase a function in a movie 
script and allow it to accept input, and then call it from the message 
window, you'll see that submitting "Hello" returns "ELLO".  So, anything 
that gets converted is included, but if something is already uppercase, it 
is not added to the output string automatically.

I also note that if you give a string like:   put uppercase("8 
02$Hello123")     that it will still give "ELLO", meaning that it properly 
ignored the other characters.

So, the only thing that you're really doing wrong is neglecting to just add 
in the character if you find it is there correctly.

I personally would probably just write it something like this:

on uppercaseII input
   output =""
   inputLen =length(input)
   aNum =charToNum("a")
   zNum =charToNum("z")

   repeat with x=1 to inputLen
     thisChar =char x of input
     thisCharNum =charToNum(thisChar)

     -- Convert if necessary
     if ((thisCharNum >=aNum) and (thisCharNum <=zNum)) then
       thisChar =numToChar(thisCharNum - 32)
     end if

       -- If valid, add it to the output
     if (thisChar >= "A" and thisChar <="Z") or (thisChar =" ") then
       output =output & thisChar
     end if

   end repeat

   return(output)
end

The only catch is the place where I convert them to thisCharNum and check 
by number.  In other languages, you can do a comparison like if 
(thisChar >="a"), because they actually compare and differentiate a small 
"a" (ascii 97) from a large "A" (ascii 65).  Lingo considers a small and a 
large "A" to be equivalent, so for the first test where we convert them, it 
has to be done by number.  If it wasn't Lingo, you could probably shave 
this in half.

In the second test, where we decide to include them or not, it's already 
been converted - all we need to know is if the member is part of the set of 
allowable characters we want, and if so, add it to the output.  Note that I 
also made a space character allowable, but that may not work for 
you.  There are, of course, many other ways to do this, but I like the 
straightforward way.  There are also ways to optimize this, but we won't 
get into that here.

- Tab

At 10:40 PM 4/10/01 +0000, N. Taylor wrote:
>To Tab:
>
>This is the script I have on the mouse Up button:
>
>global output, input
>property Uppercase
>
>on mouseUp me
>  UpperCase me
>end
>
>And this is the movie script:
>
>global input, output
>property Uppercase
>
>on Uppercase me,input
>  --  input = ForceUppercase(input)
>  --  set the text of member "userData" to input
>  input = the value of field member "userData"
>  output = EMPTY
>         num = length(input)
>         repeat with i = 1 to num
>                 theASCII = charToNum(input.char[i])
>                 if theASCII = min(max(96, theASCII), 123) then
>                         theASCII = theASCII - 32
>                         if theASCII = min(max(63, theASCII), 91) then
>                                 put numToChar(theASCII) after output
>                         end if
>                 end if
>         end repeat
>         return output
>end
>
>"userData" is the name of the field that user's can enter data 
>into.  Again, onmouseUp I'd like to take out all characters that aren't 
>letters and change the letters that exist to capitals & output just those 
>capitals.
>
>NT
>
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
>[To remove yourself from this list, or to change to digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
>email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
>Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to