How To: Delete columns of data

FlexibleLearning.com admin at FlexibleLearning.com
Tue Sep 2 14:13:21 EDT 2014


This takes 2ms to remove 4 columns from a 100x100 data table...

on mouseUp
  --| Syntax: deleteColumns <data>,<cols>
  --|     data: Specifies the data to parse
  --|     cols: A comma separated list of columns to be removed
  deleteColumns fld "Input","5,10,15,20"
  -- Specify what to do with 'the result'...
  put the result into fld "Output"
end mouseUp

-- A single variable approach
on deleteColumns pData,pColsToDelete
  split pData by column
  put item 2 of extents(pData) into tMax
  repeat with n=1 to tMax
    if n is NOT among the items of pColsToDelete then
      add 1 to x
      put pData[n] into pData[x]
    end if
  end repeat
  repeat with n=x+1 to tMax
    delete local pData[n]
  end repeat
  combine pData by column
  return pData
end deleteColumns


An enhancement request has been submitted to allow non-sequential keys to be
combined. Meanwhile, this does it.

Hugh Senior
FLCo






More information about the use-livecode mailing list