Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter EighteenDataView Integration (continued)

DataViewSetCaret Function

Overview

The DataViewSetCaret function sets the current caret position and brings the cell into view if necessary.

Syntax/Parameters

Syntax

int = DataViewSetCaret ( handle object, [int row, int column] | [string address] );

Parameters

object

A handle either to a Data View Object or to a window that employs Data View.

row and column

An optional pair of int values specifying the row and column of the cell. Or,

address

An optional string that can be used as a cell address as an alternative to specifying the row and column parameters.

Return Value

Returns an int as ERROR_NONE or a formatted error code on failure. Use the GetLastError function to retrieve error information.

Remarks

If the cell specified does not exist (such as a merge position or read-only), the caret is moved to the next available cell. This can be in the next row. If a suitable cell cannot be found, the function returns an error.

Note if a Data View Object (DVO) handle is used during an edit and caret set, the screen may reposition when the object handle is closed. For this reason, the DVO should be closed and then the caret repositioned. For example:

                                                              /****************************************/
int on_form_add_entry() {                                     /* Add an Entry                         */
                                                              /****************************************/
    handle              hDV;                                  /* Data View (for editing)              */
    string              cell[10];                             /* Cell Data                            */
    string              s1;                                   /* General                              */
    int                 rc,                                   /* Return Code                          */
                        rx, cx;                               /* Row/Column Index                     */
                                                              /*                                      */
                                                              /* ** Add an Item                       */
                                                              /*  * Are We in Valid Area              */
                                                              /*  o Current Position                  */
    s1 = DataViewGetCaret(hView);                             /* Get the position                     */
    rx = CellAddressGetRow(s1);                               /* Get the row                          */
    cx = CellAddressGetColumn(s1);                            /* Get the Column                       */
                                                              /*  o Type of Row                       */
    cell = DataViewCellGetData(hView, rx, 0);                 /* Get the current cell control cell    */
    if (cell["Comment"] != "Repeat: Yes") {                   /* Can repeat cell/Row                  */
      MessageBox('x', "Cannot add item in this area.");       /* Message                              */
      return ERROR_CANCEL_AUTO;                               /* Exit, error                          */
      }                                                       /* end error                            */
    hDV = DataViewGetObject(hView);                           /* Open an edit transaction             */
                                                              /*  * Table Add Row                     */
    rc = DataViewCloneRow(hDV, rx, 1, DC_CLONE_NO_COPY_DATA); /* Clone current row                    */
    if (IsError(rc)) {                                        /* Problem                              */
      MessageBox('x', "Internal Error #51 (0x%08X)", rc);     /* Display error                        */
      return rc;                                              /* Exit, error                          */
      }                                                       /* end non-table                        */
                                                              /*  o Position Caret                    */
    rx++;                                                     /* Next Row                             */
    CloseHandle(hDV);                                         /* Complete edit action                 */
    DataViewSetCaret(hView, rx, cx);                          /* Set the new position                 */
    return ERROR_NONE;                                        /* Done (auto update data view)         */
    }                                                         /* end function setup                   */

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL