How to start this project...

Adrian Williams adrian at clubtype.co.uk
Sun Oct 8 10:48:49 EDT 2006


Hi Mark,
Here's a graphic explanation of what I'm trying to do here...
http://www.clubtype.co.uk/revDev-abc/abc-rev.jpg

I'm miles away from dealing with a list of replacement characters yet,
  but in the meantime, I just need to get started on the proper method
of detecting:
Where the cursor is when its clicked in the text field?
Because it may be at the line beginning or in the middle of a word.
The function 'selectedChunk' returns the position of the entered
character in the form of...
char 1 to 0 of field 1 (the first character in the field)
char 1 to 2 of field 1 (the second character in the field)
etc, etc.
So from that, how does Jacqueline get a simple plus or minus value...?
I quote...

> Look up the "selectedChunk" term in the dictionary. This gives you the 
> position of the insertion point, or the position of any selected text, 
> in the format:
>
>   char x to y of field "whatever"
>
> If x is smaller than y, a range of characters is selected. If x is 
> larger than y, the insertion point is blinking between two characters. 
> Your script should check to see whether x is smaller than y.  If so, 
> you've got a selection that spans characters, and x-1 would be the 
> previous character, and y+1 would be the next one. If x is larger than 
> y, the insertion point is between characters and x+1 would be the next 
> character and y-1 would be the previous one.

Thanks for any clarity.
Adrian
_____________________
Club Type
http://www.clubtype.co.uk
adrian at clubtype.co.uk

On 3 Oct 2006, at 18:51, Adrian Williams wrote:

> I decided to start with a simple function,
> before getting involved with what to do with the return value....
>
> On 2 Oct 2006, at 10:47, Martin Blackman wrote:
>
>> Jacqueline covered it much better than me there. The lookupchar
>> function was indeed intended as a separate function for you to write.
>> eg. you might do something like this
>>
>> -- field "input" contains list of chars which should be replaced, eg 
>> "ABC"
>> -- field "output" contains your desired output chars in matching 
>> order, eg "123"
>>
>> function lookupchar tchar
>>    get offset (tchar,field "input")
>>    if it = 0 then return tchar else \
>>            return char it of field "Output"
>> end lookupchar
>>
> So... I made a new main Stack: lookup.rev,
> created three fields: editedText, input, output,
> and a button to run the script.
>
> ABC is first line of 'input' field.
> 123 is first line of output filed.
> in field editedText, ABC is entered.
> Button is pressed.
> Result: "Error in handler"
> Hint: function.
>
> This function should work in its own right - yes?
> Adrian
>
> _______________________________________________
> 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


More information about the use-livecode mailing list