Example ObjectRepository importTab 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 importTab, i.e., refImport, and setImport and
provides additional methods: refRowCount and refColCount which queries
the Lambda how many rows and columns have been imported and doClear
which performs initialization of persistent variables.
(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) ;; Mandatory child function for importTab
(setq rowVector[row] record) ;; Install the data in a vector
(setq rowCount row) ;; Update the row count
rowCount) ;; end of setImport
(defun refExport(rowIndex) ;; Mandatory child function for exportTab
(if (>= rowIndex rowCount) (return false)) ;; Return "false" to stop the export
(return rowVector[rowIndex])) ;; Pass a filled record to exportTab.
(defun refImport(row) ;; Mandatory child function for importTab
(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
Returns:
Here are examples of the importTab function at work.
Lambda importTab 001 | ObjectRepository importTab 001 |
Here is the link to the current function used in this example.
Here are a number of links to other related functions.
exportTab(#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
|