sps.c
State selectFind_cmd(Context ctx) {
    // copy original string
    char searchStr[strlen(ctx.argStr) + 1];
    strcpy(searchStr, ctx.argStr);
    // remove the ] at the end
    searchStr[strlen(ctx.argStr)-1] = '\0';

    // go through every selected cell
    for (unsigned i=selUpperBound(ctx.table); i <= selLowerBound(ctx.table); i++) {
        for (unsigned j=selLeftBound(ctx.table); j <= selRightBound(ctx.table); j++) {
            Cell *cellPtr = getCellPtr(ctx.table, i, j);
            if (strcmp(cellPtr->str, searchStr) == 0) {
                selectCell(ctx.table, i, j);
                return SUCCESS;
            }
        }
    }
    return SUCCESS;
}
// select the first cell, where str argument matches
select the first cell, where str argument matches
select the first cell where str argument matches
State selectFind_cmd(Context ctx) {
    char searchStr[strlen(ctx.argStr) + 1];
    strcpy(searchStr, ctx.argStr);
    searchStr[strlen(ctx.argStr)-1] = '\0';
    for (unsigned i=selUpperBound(ctx.table); i <= selLowerBound(ctx.table); i++) {
        for (unsigned j=selLeftBound(ctx.table); j <= selRightBound(ctx.table); j++) {
            Cell *cellPtr = getCellPtr(ctx.table, i, j);
            if (strcmp(cellPtr->str, searchStr) == 0) {
                selectCell(ctx.table, i, j);
                return SUCCESS;
            }
        }
    }
    return SUCCESS;
}
State selectFind_cmd ( Context ctx ) { char searchStr [ strlen ( ctx . argStr ) + 1 ] ; strcpy ( searchStr , ctx . argStr ) ; searchStr [ strlen ( ctx . argStr ) - 1 ] = ' \0 ' ; for ( unsigned i = selUpperBound ( ctx . table ) ; i <= selLowerBound ( ctx . table ) ; i ++ ) { for ( unsigned j = selLeftBound ( ctx . table ) ; j <= selRightBound ( ctx . table ) ; j ++ ) { Cell * cellPtr = getCellPtr ( ctx . table , i , j ) ; if ( strcmp ( cellPtr -> str , searchStr ) == 0 ) { selectCell ( ctx . table , i , j ) ; return SUCCESS ; } } } return SUCCESS ; }
select the first cell, where str argument matches
select the first cell where str argument matches
// copy original string // remove the ] at the end // go through every selected cell