How to start this project...

Adrian Williams adrian at clubtype.co.uk
Tue Oct 10 11:05:48 EDT 2006


Jacqueline,
Works a treat - thanks!

Two things...
1.
I think it would be neater to have all the calculating of user input
in a function somewhere else - in another card, not in the text field 
being edited.
(There may be other text fields requiring slightly different joining 
calculations).
I tried to identify ONLY lower case letters in the edited text field 
because only those need to join.
But Rev treats "a" just like "A" and "b" just like "B" etc.
case pChar "a" returns CAPS too.
[a-z]" failed.
set the HTML failed.

2. Having filtered out all but the lower case, how can I call on a 
function thats
somewhere else (from the text field). Should pChar be global?

function joinChar pChar
switch
case pChar is "a" or pChar is "b" return "~"
-- don't do the case thing, 
-- go to a function and match pChar to
-- a list of Input and Output values for replacement
-- just replace a with z for now
break
end switch
end joinChar

Rev. docs state...
Unicode characters whose numeric value is greater than 255 are
encoded as "bignum" entities, with a leading ampersand and trailing 
semicolon.
For example, the Japanese character whose numeric value is 12387 is 
encoded as "っ".

So I guess that's the way to label the characters of pChar that require 
joining?
Also labeled that way in the Input and Output lists for replacement?
Thanks,
Adrian

On 10 Oct 2006, at 01:20, J. Landman Gay wrote:

> Adrian Williams wrote:
> > Hi Jacqueline,
> >
> > I realise now the selectedChunk is certainly the wrong way to go!
>
> Well, now that you've explained more about it, I think you actually do 
> have to use this.
>
> It looks like you want to add intermediate characters between the ones 
> the user types, except at the beginning of words. You use a space as 
> the word delimiter in your example, but I think you'd have to handle 
> line beginnings too. For simplicity, let's just check for spaces and 
> carriage returns.
>
> In a field, you'd put a script something like this:
>
> on keydown pkey
>   put the selectedChunk into tChunk
>   put word 2 of tChunk - 1 into tPrevCharNum -- a number
>   put char tPrevCharNum of me into tPrevChar -- this is a character
>   if tPrevChar <> space and tPrevChar <> cr and tPrevCharNum <> 0 then 
> -- not a word start
>     put joinChar(tPrevChar) into tKeys  -- calls a function
>   end if
>   put pkey after tKeys -- adds the user-typed entry to tKeys variable
>   do "put tKeys into" && tChunk
> end keydown
>
> function joinChar pChar
>   return "~"
> end joinChar
>
> This catches keystrokes, calculates the previous character position, 
> and checks that character to make sure it isn't the first character in 
> the field, a space, or a carriage return. If the criteria are met, it 
> calls a function that returns the join character. In my example, 
> that's just a tilde. You'd have to write the guts of the function, 
> which you would base on the value of the parameter "pChar" which is 
> passed to the function. The tilde is inserted into a variable, and 
> then user's keystroke is added to it. The two characters are then 
> placed into the field using the "do" construct, which is necessary 
> here in order to evaluate the variable "tChunk" when using it in a 
> command. (Don't ask.)
>
> That said, when you start using unicode, some of this will break. The 
> text chunking capabilities in Rev are one of its strongest points, but 
> they break down somewhat when using unicode. I'm a bit weak in that 
> area myself, so hopefully someone here can join in and suggest how to 
> alter the above to account for the additional bytes that unicode 
> requires. I think you have to add/subtract 2 rather than 1 for all the 
> calculations, but I haven't tried it.
No offers yet!
>
> Maybe this will at least get you started on how to calculate text 
> chunks and how to call a function.
>
> -- 
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
_______________________________________
Adrian Williams Design Ltd (trading as Club Type),
44 Mill Lane,
Merstham,
Redhill,
Surrey RH1 3HQ, UK

Telephone/Facsimile: 01737 643300
dFax (computer reception): 0870 0515681

International tel/fax (UK)+44 1737 643300
International dFax:  (UK)+44 870 0515681

Email: adrian at clubtype.co.uk
Website: http://www.clubtype.co.uk



More information about the Use-livecode mailing list