Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb example for micros ISL 1

Status
Not open for further replies.

microsguru2

IS-IT--Management
Oct 18, 2012
15
US
Does anyone have any vb sample code that parses the data received from a micros ISL script? (txmsg)​
 
What exactly are you wanting to do or look for? You can parse through with ISL script.
 
I could offer a perl script that parses through it to grab info you specify.

What are you wanting to grab from the file?
 
I don't think he's wanting to parse the ISL. I think he's asking how to parse the formatted data that gets sent via TCP/IP when you use the txmsg command.
 
I have a script that I did in perl that goes through the log file for XXX data the end user enters. You can use it to parse through the log file for the info, as you can make any changes to it to find the data you are looking for. The script exports the info to a log file.
 
If I am thinking of the correct info, on the 9700 system it is saved to a pmsXXX.log file. Which could be a check mark option in the interface that is used.
 
Sorry, I got slammed in work since I posted this. Moregelen, you are correct. I am looking to take the transmitted data (the variable length data) in the string and perform some sql statements with it. I think i need to do either a regex or substring in vb?
 
Well, the easiest method would be to convert the bytes to a string and then pull out the substrings you need. You could also handle it blocks of bytes given a lot of it involves fixed width data. The actual data being sent by the message is variable in length, but the checksum could help with that. Something like this would work (taking it with a grain of salt given it's a fairly crude mockup that hasn't been tested)

Code:
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');
 
hosehead78, you're thinking of parsing the log file for an existing interface. It sounds like rjdpa2 is basically trying to create his own interface. The log files aren't going to help you for real time traffic using txmsg and rxmsg if there isn't anything there actually receiving and processing the messages, which is what rjdpa2 seems to be trying to develop.
 
Thank you Moregelen for the input & sample! I will give that a shot :)
 
No problem. I actually have a DLL I use at this point, so I don't really have to worry about it anymore :)

I create aa server like this these days:

MicrosServer ms = new MicrosServer(3276); //the port I'm binding on

Then I just sit there looping and doing:

MicrosClient mc = ms.GetClient();

My micros client has some exposed methods like mc.Send(...) where I can specify which event I'm triggering in the SIM and such. And I can also do a nice MicrosMessage mm = mc.GetMessage(); which returns me a nice little black box with all the pieces properly named for me. Heheh. Been a while since I actually thought about the code I wrote way back when (almost three years ago now) to actually handle parsing and then formatting the messages for the return. Plus handling things like the keep alive messages. I should probably crack that open at some point to read through it all again but... naaah. It seems to be working fine and thats the whole point of OOP, no?
 
I have some docs on what's and how things are expected from micros. I can post them monday. If you want them, I think they could help.
 
The link above has a screenshot of pretty much everything you need for handling the messages. For a single page worth of doc in the SIM book, its surprisingly helpful.
 
Sure hosehead78. Thank you!

Basically, what i'm trying to accomplish is to prompt the cashier/server for a card number. When the card number is scanned I am going to go to another sql database and run a select statement and see if that card number qualifies for a discount. If so, return the discount object number back to micros and apply it (using loadkbmacro) or another function.

Would it be smarter to use a DLL as opposed to using "txmsg"/"rxmsg"?
 
Is the database going to be stored on the Micros database in a custom table, or a database somewhere else?

And if it IS going to be stored somewhere else, can you setup something like a System DSN to make an ODBC connection to it?

If so, Micros actually already has a built in DLL that you can use to make database calls from within a SIM, no external program required.
 
The site I am at using custom interfaces to pass info back and forth, we do not use other dlls or files to do this. The db's are on a different server. The interface sends the rxmsg to and waits for the return. The isl script handles the information to and from the interface. It catches the card swipe, coupon scan and such and sends it off and based on the card it will return the requested info or denial/failure.
 
It will be on another server, and yes, i do have the ability to define that info from the micros server. I'll have to revisit the SIM document and look into that, unless it is in another doc?
 
Here is a sample. I have a functions.isl file that is usually use in my scripts, which contains this:

Code:
/////////////////////////////////////////////////
///////////        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


Then, when I want to use it in a new script... in this example, pms8.isl or something (making a point here that its a separate file) I'll do:

Code:
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


Of course, the only reason I keep it in a separate file is to make the code a bit easier for me to read. Most of these though have it all in one file, which is perfectly fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top