Dumb XML library question

BNig bernd.niggemann at uni-wh.de
Thu Aug 7 03:06:39 EDT 2014


for the record
Pete wants to cycle trough tab delimited data in a scrolling field with the
tab key forward and tab-shift key to go backwards

The solutions I posted above don't take into account an empty cell.

Here is a script that places the cursor into  empty cells for data of type

data tab data tab data return
data tab empty tab

no return at the end of the field

---------------------------------------------------------

on tabKey
   set the itemDelimiter to tab
   put the selectedChunk into tSelect
   if the shiftKey is down then
      put word 4 of tSelect into tIndex
   else
      put word 2 of tSelect into tIndex
   end if
   
   if not ( the shiftKey is down) then
      -- find next tab
      put tIndex into tCounter
      put offset(tab,me,tCounter) into tNextTab
      if tNextTab > 0 then 
         add tNextTab to tCounter
         put tCounter into tForWardPos
      else
         put the number of chars of me into tForwardPos
      end if
      
      -- find next return
      put offset(return,me,tIndex) into tNextReturn
      if tNextReturn <> 0 then
         add tIndex to tNextReturn
      else
         put the number of chars of me into tNextReturn
      end if
      
      if (tNextReturn < tForwardPos) then
         select before char tNextReturn of me
      end if
      -- both have the number of chars as values, end of text
      if (tNextReturn = tForwardPos) then 
         select after char tNextReturn of me
      end if
      if (tNextReturn > tForwardPos) then
         select before char tForwardPos of me
      end if
      
   else --- shiftKey is down
      
      -- go backwards to find previous tab or return
      repeat with i = tIndex down to 0
         if char i of me = tab or char i of me = return or i  = 0  then
            put i into tFound
            exit repeat
         end if
      end repeat
      
      -- go forward to find from previous delimiter  
      -- next delim and place cursor before delim
      repeat with j = tFound to the number of chars of me
         if char j of me = tab or char j of me = return then
            put j into tFound
            exit repeat
         end if
      end repeat
      select before char tFound  of me
   end if
end tabKey
------------------------------------------------------------

tested on LC 6.6.2, 6.7DP7, 7.0DP8

watch out for line breaks

Kind regards
Bernd



--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Shift-tab-tp4681722p4681824.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list