SQUID Functions

 

  • The SQUID functions, and their examples, assume that the SQUID server has been started with an address of http://localhost:8000.
  • Validation of the function calls can be handled by checking the return value and calling SquidGetLastError().

 

Thursday
Feb212013

SquidBatch

  • Executes a delimited set of SQUID functions.
  • Does not allow nested SQUID calls (SQUID functions as parameters to other SQUID functions).
  • All batched SQUID functions act on the iSquid instance passed into SquidBatch.
  • All SQUID functions available except: SquidBatch, SquidConnect, SquidDisconnect.

Prototype

int SquidBatch(int iSquid, char* sCommands, char* sDelimiter);

  • Parameters
iSquidSquid Connection Handle
sCommandsString containing the delimited set of SQUID functions
sDelimiterDelimiter used to separate the SQUID commands and their parameters
  • Return Values
""Operation successful
char*String containing command errors

Example

int iSquid;
int i;
char *ptr;
char strCommand[8192];
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
strCommand[0] = 0;
ptr = strCommand;
for (i=1; i<=100; i++)
{
ptr += sprintf(ptr, "SquidSendData;Column1;LR-BATCH-%d;", i);
}
lr_output_message("SquidBatch command = %s", strCommand);
lr_output_message("SquidBatch=%s", SquidBatch(iSquid,strCommand,";"));
lr_output_message("SquidGetLastError = %s", SquidGetLastError(iSquid));
SquidDisconnect(iSquid);

Thursday
Feb212013

SquidClearAllColumns

  • Clears all data in all the columns.  All content will be lost.
  • Removes all the data tabs from SQUID.
  • Allows for the cleaning out of the data without having to close and reopen SQUID.

Prototype

int SquidClearAllColumns(int iSquid);

  • Parameters
iSquidSquid Connection Handle
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidSendData(iSquid, "Column 1", "Some Data");
SquidSendData(iSquid, "Column 2", "More Data");
SquidSendData(iSquid, "Column 3", "Last Data");
SquidClearAllColumns(iSquid);
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidClearColumn

  • Clears all data in a column given the column name.  Content will be lost.
  • Removes the tab from SQUID.

Prototype

int SquidClearColumn(int iSquid, char* sParam);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "Some Data");
SquidClearColumn(iSquid, "NewColumn");
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidClearData

  • Clears all data in a row given the row index.
  • Returns the data that was removed from SQUID.

Prototype

char* SquidClearData(int iSquid, char* sParam, int iIndex);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
iIndexRow index of the row to clear (1-based)
  • Return Values
char*Operation successful, data that was removed
""Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "Data Row 1");
SquidSendData(iSquid, "NewColumn", "Data Row 2");
SquidSendData(iSquid, "NewColumn", "Data Row 3");
SquidClearData(iSquid, "NewColumn", 1);
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidClearRow

  • Clears/removes a row from all columns (all tabs).
  • If a particular column does not have enough rows, this column is ignored (no error).

Prototype

int SquidClearRow(int iSquid, int iIndex);

  • Parameters
iSquidSquid Connection Handle
iIndexRow index of the row to clear/remove (1-based)
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "20");
SquidSendData(iSquid, "NewColumn", "100");
SquidSendData(iSquid, "OtherColumn", "50");
SquidSendData(iSquid, "OtherColumn", "30");
SquidSendData(iSquid, "OtherColumn", "80");
SquidClearRow(iSquid, 1);
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidColumnSize

  • Returns the number of rows in the column.

Prototype

int SquidColumnSize(int iSquid, char* sParam);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
  • Return Values
>=0The number of rows in the column
-1Error occurred, call SquidGetLastError for details

Example

int iCount;
int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "20");
SquidSendData(iSquid, "NewColumn", "100");
SquidSendData(iSquid, "NewColumn", "50");
iCount = SquidColumnSize(iSquid, "NewColumn");
lr_output_message("Rows in NewColumn = %ld", iCount);
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidConnect

  • Generates a SQUID connection.
  • Must be called before any other SQUID functions.

Prototype

int SquidConnect(char* sServer);

  • Parameters
sServerEndpoint address of a SQUID server that has been started
  • Return Values
>0Operation successful, SQUID connection pointer
<=0Error occurred

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "20");
SquidSendData(iSquid, "NewColumn", "100");
SquidSendData(iSquid, "NewColumn", "50");
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidCreateColumn

  • Creates a column (tab) in SQUID.

Prototype

int SquidCreateColumn(int iSquid, char* sParam);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "20");
SquidSendData(iSquid, "NewColumn", "100");
SquidSendData(iSquid, "NewColumn", "50");
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidDisconnect

  • Disconnects from SQUID.
  • Before using SQUID again, SquidConnect must be called.

Prototype

int SquidDisconnect(int iSquid);

  • Parameters
iSquidSquid Connection Handle
  • Return Values
0Operation successful
<0Error occurred

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "20");
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidExportData

  • Export column data to a file.
  • The data is not removed from the column in SQUID.
  • The first row of the file will contain the parameter name.
  • If the UI is being used, click the '...' to display the file save dialog.

Prototype

int SquidExportData(int iSquid, char* sParam, char* sFilePath, int iOption);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
sFilePathFile to export
iOption=0 Overwrite file
=1 Create a backup first (if file exists)
=2 If file exists, do nothing, return error
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "20");
SquidSendData(iSquid, "NewColumn", "100");
SquidSendData(iSquid, "NewColumn", "50");
SquidExportData(iSquid, "NewColumn", "c:\\users_exported.dat", 1);
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidGetLastError

  • Returns the last error on the connection handle (SQUID pointer).
  • SQUID function return values should also be checked.

Prototype

char* SquidGetLastError(int iSquid);

  • Parameters
iSquidSquid Connection Handle
  • Return Values
char*Last reported error
""The last operation was successful

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "20");
SquidSendData(iSquid, "NewColumn", "100");
SquidSendData(iSquid, "NewColumn", "50");
SquidRetriveData(iSquid, "NewColumn");
lr_output_message("%s",SquidGetLastError(iSquid));
SquidRetriveData(iSquid, "NewColumnXXX");
lr_output_message("%s",SquidGetLastError(iSquid));
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidImportData

  • Import data into SQUID.
  • The first row of the file will contain the parameter name.
  • If the UI is being used, click the '...' to display the file open dialog.

Prototype

int SquidImportData(int iSquid, char* sFilePath);

  • Parameters
iSquidSquid Connection Handle
sFilePathPath of data file to import
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidImportData(iSquid, "c:\\users_to_import.dat");
SquidDisconnect(iSquid);

Import File

users
user001
user002
user003
user004

Sunday
Feb192012

SquidIncrementData

  • Increments a counter at a specified column and index.
  • Returns the new number.

Prototype

int SquidIncrementColumn(int iSquid, char* sParam, int iIndex, int iIncrement);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
iIndexRow index of the row to increment (1-based)
iIncrementAmount to adjust the current value by (can be negative)
  • Return Values
intNewly incremented number
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "20");
SquidSendData(iSquid, "NewColumn", "100");
SquidSendData(iSquid, "NewColumn", "50");
SquidIncrementColumn(iSquid, "NewColumn", 1, -5);
SquidDisconnect(iSquid);

Thursday
Feb212013

SquidIsDirty

  • Determines if the data displayed in SQUID is up to date.

Prototype

int SquidIsDirty(int iSquid, char* sParam);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
  • Return Values
0SQUID is up to date
1SQUID is dirty, not all data has been written to SQUID
-1Error occurred, call SquidGetLastError for details

Example

// SquidSendData 10000 times, wrapped in SquidPause/SquidResume calls and
// calling SquidRefresh every 1000 sends.
int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidPause (iSquid, "col");
for (i=1; i<=10000; i++)
{
if (i==5000)
{
lr_output_message("dirty=%d", SquidIsDirty(iSquid,"col"));
}
sprintf (strBuffer, "LR-SEND3-%03d-%05d", iVuserId, i);
SquidSendData (iSquid, "col", strBuffer);
if (i % 1000 == 0)
{
SquidRefresh (iSquid, "col");
}
if (i==5000)
{
lr_output_message("dirty=%ld", SquidIsDirty(iSquid,"col"));
}
}
SquidResume (iSquid, "col");
SquidDisconnect(iSquid);

Wednesday
Feb202013

SquidNoOperation

  • No operation is performed on SQUID.
  • Can be used to verify the communication with SQUID.

Prototype

int SquidNoOperation(int iSquid);

  • Parameters
iSquidSquid Connection Handle
  • Return Values
0Operation successful

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
lr_output_message("%ld",SquidNoOperation(iSquid));
SquidDisconnect(iSquid);

Thursday
Feb212013

SquidPause

  • Pauses the updating of SQUID.
  • All SQUID calls will be cached until SquidResume or SquidRefresh is called.
  • If the column does not exist, it will be created.

Prototype

int SquidPause(int iSquid, char* sParam);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

// SquidSendData 10000 times, wrapped in SquidPause/SquidResume calls and
// calling SquidRefresh every 1000 sends.
int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidPause (iSquid, "col");
for (i=1; i<=10000; i++)
{
if (i==5000)
{
lr_output_message("dirty=%d", SquidIsDirty(iSquid,"col"));
}
sprintf (strBuffer, "LR-SEND3-%03d-%05d", iVuserId, i);
SquidSendData (iSquid, "col", strBuffer);
if (i % 1000 == 0)
{
SquidRefresh (iSquid, "col");
}
if (i==5000)
{
lr_output_message("dirty=%ld", SquidIsDirty(iSquid,"col"));
}
}
SquidResume (iSquid, "col");
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidQueryColumn

  • Retrieves all data from a column in SQUID.
  • The data is not removed from SQUID.

Prototype

char* SquidQueryColumn(int iSquid, char* sParam, char* sDelimiter);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
sDelimiterDelimiter used to separate data values
  • Return Values
char*Operation successful, column data retrieved
""Error occurred, call SquidGetLastError for details

Example

char* ptr;
int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "Data Row 1");
SquidSendData(iSquid, "NewColumn", "Data Row 2");
SquidSendData(iSquid, "NewColumn", "Data Row 3");
ptr = SquidQueryColumn(iSquid, "NewColumn", ";");
lr_output_message("NewColumn = %s", ptr);
ptr = SquidQueryColumn(iSquid, "NewColumn", "*$*");
lr_output_message("NewColumn = %s", ptr);
SquidDisconnect(iSquid);

Sunday
Feb192012

SquidQueryData

  • Retrieves data from a column in SQUID at the specified index (row).
  • The data is not removed from SQUID.

Prototype

char* SquidQueryData(int iSquid, char* sParam, int iIndex);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
iIndexRow index of the row to query (1-based)
  • Return Values
char*Operation successful, data element retrieved
""Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidCreateColumn(iSquid, "NewColumn");
SquidSendData(iSquid, "NewColumn", "Data Row 1");
SquidSendData(iSquid, "NewColumn", "Data Row 2");
SquidSendData(iSquid, "NewColumn", "Data Row 3");
SquidQueryData(iSquid, "NewColumn", 1);
SquidDisconnect(iSquid);

Thursday
Feb212013

SquidRefresh

  • All cached information will be written to SQUID and be available to all users.
  • Calls SquidIsDirty. If not dirty, nothing is done (all has been written).

Prototype

int SquidRefresh(int iSquid, char* sParam);

  • Parameters
iSquidSquid Connection Handle
sParamString containing the name of the column
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

// SquidSendData 10000 times, wrapped in SquidPause/SquidResume calls and
// calling SquidRefresh every 1000 sends.
int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidPause (iSquid, "col");
for (i=1; i<=10000; i++)
{
if (i==5000)
{
lr_output_message("dirty=%d", SquidIsDirty(iSquid,"col"));
}
sprintf (strBuffer, "LR-SEND3-%03d-%05d", iVuserId, i);
SquidSendData (iSquid, "col", strBuffer);
if (i % 1000 == 0)
{
SquidRefresh (iSquid, "col");
}
if (i==5000)
{
lr_output_message("dirty=%ld", SquidIsDirty(iSquid,"col"));
}
}
SquidResume (iSquid, "col");
SquidDisconnect(iSquid0;

Thursday
Feb212013

SquidRenameColumn

  • Renames a column in SQUID.

Prototype

int SquidRenameColumn(int iSquid, char* sFromColumn, char* sToColumn);

  • Parameters
iSquidSquid Connection Handle
sFromColumnExisting column name to be renamed
sToColumnNew column name
  • Return Values
0Operation successful
-1Error occurred, call SquidGetLastError for details

Example

int iSquid;
lr_load_dll("SQUID-REST.dll");
iSquid = SquidConnect("http://localhost:8000");
SquidSendData(iSquid, "Column 1", "user001");
SquidRenameColumn(iSquid, "Column 1", "users");
SquidDisconnect(iSquid);