microsguru2
IS-IT--Management
Does anyone have any vb sample code that parses the data received from a micros ISL script? (txmsg)
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
string message = "";
byte[] buffer = new byte[4096];
int bytesRead;
while (!message.Contains("" + '\x004'))
{
try
{
bytesRead = stream.Read(buffer, 0, 4096);
if (bytesRead > 0)
{
ASCIIEncoding encoder = new ASCIIEncoding();
message += encoder.GetString(buffer, 0, bytesRead);
}
}
catch (Exception) { }
}
string InterfaceName = message.Substring(10, 16);
string TransmissionNumber = message.Substring(28, 2);
string RetransmissionFlag = message[30];
string[] DataParts = message.Substring(31, message.Length - 31 - 6).Split('\x1C');
/////////////////////////////////////////////////
/////////// SQL FUNCTIONS ///////////
/////////////////////////////////////////////////
SUB LOADSQL
CALL LOADDLL
CALL OPENSQL
ENDSUB
SUB LOADDLL
IF SQL_H = 0
DLLLOAD SQL_H, "MDSSysUtilsProxy.dll"
ENDIF
ENDSUB
SUB OPENSQL
IF SQL_H = 0
RETURN
ENDIF
VAR CON_STATUS : N9
DLLCALL_CDECL SQL_H, sqlIsConnectionOpen( REF CON_STATUS )
IF CON_STATUS = 0
DLLCALL_CDECL SQL_H, sqlInitConnection("micros", "ODBC;UID=custom;PWD=custom", "")
ENDIF
ENDSUB
SUB SQL_QUERY( REF SQL_CMD )
DLLCALL_CDECL SQL_H, sqlGetRecordSet( SQL_CMD )
SQL_CMD = ""
DLLCALL_CDECL SQL_H, sqlGetLastErrorString( REF SQL_CMD )
IF SQL_CMD <> ""
ERRORMESSAGE "SQL ERROR: ", SQL_CMD
ENDIF
DLLCALL_CDECL SQL_H, sqlGetNext( REF SQL_CMD )
ENDSUB
SUB SQL_EXEC( REF SQL_CMD )
DLLCALL_CDECL SQL_H, sqlExecuteQuery( SQL_CMD )
SQL_CMD = ""
DLLCALL_CDECL SQL_H, sqlGetLastErrorString( REF SQL_CMD )
IF SQL_CMD <> ""
ERRORMESSAGE "SQL ERROR: ", SQL_CMD
ENDIF
ENDSUB
SUB SQL_RECORDSET( REF SQL_CMD )
DLLCALL_CDECL SQL_H, sqlGetRecordSet( sql_cmd )
SQL_CMD = ""
DLLCALL_CDECL SQL_H, sqlGetLastErrorString( REF SQL_CMD )
IF SQL_CMD <> ""
EXITWITHERROR "SQL Error: ", SQL_CMD
ENDIF
ENDSUB
SUB SQL_NEXTRECORD( REF SQL_CMD )
DLLCALL_CDECL SQL_H, sqlGetNext( REF SQL_CMD )
ENDSUB
SUB CLOSESQL
IF SQL_H <> 0
DLLCALL_CDECL SQL_H, sqlCloseConnection()
DLLFREE SQL_H
ENDIF
SQL_H = 0
ENDSUB
include functions.isl
sub LookupCard(var card : a20, ref Result)
[indent]call loadsql[/indent]
[indent]var sql_cmd : A2000[/indent]
[indent]format sql_cmd as "select discount_available from custom.some_table where card = ", card[/indent]
[indent]call sql_query( sql_cmd )[/indent]
[indent]var yes_no : N1 = sql_cmd //sql_cmd now contains your query result. In my hypothetical here, 0 = no, 1 = yes, so Im now casting it into an integer[/indent]
[indent]if yes_no = 1[/indent]
[indent][indent]Result = "something positive" //just an example of how you can pass data back out of the sub[/indent][/indent]
[indent]else[/indent]
[indent][indent]Result = "something negative"[/indent][/indent]
[indent]endif[/indent]
endsub