adding information to table cells

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

adding information to table cells

Post by Glenn Boyce » Wed May 06, 2009 4:32 am

I have some time information in column 1 on a table. I wish to add another time in column 2 at a later date, subtract one from the other and put it into column 3. Sounds easy enough but even though I've put set itemdelimiter to tab before the entering the data in column 2 it puts it into column 1 after the existing time and separates it with a comma?

Code: Select all

on mouseUp
  if fld "runStart" = "" then
  put the time into fld "RunStart"
  send mouseup to button "Start Counter"
else
set itemdelimiter to tab
  put the time into item 2 of line glineNo of fld "log"
  put (item 2 of line glineNo of fld "log") - (item 1 of line glineNo of fld "log") into item 3 of line glineNo of fld "log"
  end if
end mouseUp

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Wed May 06, 2009 5:57 am

Hi Glenn,

Apart from the fact that Rev doesn't do time arithmetic like that, you should also take the nature of your table field into consideration. If you've turned on the Table behaviour using the inspector, you shouldn't just set data inside the table field directly.

Code: Select all

on mouseUp
  if fld "runStart" = "" then 
    put the time into fld "RunStart" 
    send mouseup to button "Start Counter" 
  else
    global gLineNo
    set the itemDelimiter to tab 
    put the time into tEndTime
    put item 1 of line glineNo of field "log" into tStartTime
    convert tEndTime from time to seconds
    convert tStartTime from time to seconds
    put the long id of field "log" into tField
    SetCellValue tField, 2, gLineNo, tEndTime
    SetCellValue tField, 3, gLineNo, tEndTime - tStartTime
  end if 
end mouseUp

on SetCellValue pObject, pColumn, pRow, pData
  send "revWriteCellValue pObject, pRow, pColumn, pData" to pObject
end SetCellValue
The datagrids in Revolution 3.5 would probabl make this a lot easier, though...

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply