Example ObjectRepository exportTab 001
|
The stockLambda Lambda is a simple Lambda that reads a file, and imports
the data into an in-memory table that is represented as an Object Vector. Each item in
the object Vector is a record. Note that the stockLambda example supplies the minimum
method needed by exportTab, i.e., refExport, and provides two additional
methods: refRowCount and refColCount which queries the Lambda how many rows
and columns have been imported.
(defun StockLambda()
pvars: (rowCount colCount rowVector colVector)
(defun doClear() ;; Manage clear at start of import.
(setq rowCount 0) (setq colCount 0)
(setq colVector #void)
(setq rowVector (^new Vector: object: 0))) ;; end of doClear
(defun setImport(row record)
(setq rowVector[row] record) ;; Install the data in a vector
(setq rowCount row) ;; Update the row count
rowCount) ;; end of setImport
(defun refExport(rowIndex)
(if (>= rowIndex rowCount) (return false)) ;; Return "false" to stop the export
(return rowVector[rowIndex])) ;; Pass a filled record to exportTab.
(defun refImport(row)
(return (^new String: 256))) ;; Pass an empty string container to importTab.
(defun refRowCount() rowCount)
(defun refColCount() colCount)
)
Returns:
(define myLambda (new StockLambda)) ;; Create a new instance of the StockLambda
(myLambda.doClear) ;; initialize persistent variables
(setq fileid (fileOpen "stocks.sbf" 0 0)) ;; Open an existing text file
(importTab fileid myLambda recordsOnly:) ;; Import the file
(fileClose fileid 1) ;; Close the file
(myLambda.refRowCount) ;; Ask the Lambda for a row count
(setq fileid (fileOpen "newStocks.sbf" 1 0)) ;; Create a new text file
(setq rowsOut (exportTab fileid myLambda recordsOnly:));; export the file
(fileClose fileid 1) ;; Close the file
(myLambda.refRowCount) ;; Ask the Lambda for a row count
Returns:
Here are examples of the exportTab function at work.
Lambda exportTab 001 | ObjectRepository exportTab 001 |
Here is the link to the current function used in this example.
Here are a number of links to other related functions.
importTab(#void) |
Here are the links to the data types of the arguments used in this example. Here are a number of links to examples having similar argument types.
ObjectRepository
ObjVector
Analytic Information Server (AIS)AIS Component Systems
|