table format in Rev 2

Jan Schenkel janschenkel at yahoo.com
Thu Apr 10 16:08:01 EDT 2003


--- Yves COPPE <yvescoppe at skynet.be> wrote:
> Hi,
> 
> I write you off-list to ask you something.
> I've made a table with your scripts. OK
> 
> 
> Two questions :
> 
> 1° Now I'd like to make a text editable table
> 
> So my porblem is
> 
> when I hit the return key, the cursor must come on
> the following
> line, before the text if any
> 
> when I hit the tab key, the cursor must come on the
> same line of the
> next fld. If I am on the last fld of the table, the
> cursor must come
> on the same line of the first fld
> 
> Can you write for me the script to make such a thing
> ??
> 
> 
> 2° how can I align the text of an editable fld of a
> table to the
> decimal (here the decimal is a comma)  ??
> 
> Thank you for your help.
> --
> Greetings.
> 
> Yves COPPE
> 

Hi Yves,

My apologies for not aving reacted sooner ; project
gobbling up all my time and my beloved likes to spend
time with me as well, it seems  *chuckle*
At any rate, let's se what we can do :

1) try something like this

on returnInField
  put word 2 of the selectedLine into tCurrentLine
  if tLine = the number of lines of me then beep
  else select before line tCurrentLine + 1 of me
end returnInField

on tabKey
  put word 2 of the selectedLine into tCurrentLine
  -- NOTE :: easiest with a custom property
  --         named uNextField for your field
  put the uNextField of me into tNextField
  select before line tCurrentLine of fld tNextField
end tabKey

2) You'll have to right-align the field and format the
numbers to the same number of decimals, so as to add
trailing zeroes ; or use a fixed width font and append
spaces.
You could do this formatting on returnInField.

If you can't append spaces, nor use a fixed-width
font, you'll have to figure out how wide a space is in
the font of your choice, so that you can append as
many as you need.
Add this to your field script to calculate that width:

function Calculate1SpaceWidth
  lock screen
  put return & space after me
  put the formattedWidth of line -1 of me into tWidth
  delete char -2 to -1 of me
  unlock screen
  return tWidth
end Calculate1SpaceWidth

[Sending a copy to the use-rev list so people there
can use this stuff as well.]

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com



More information about the use-livecode mailing list