Inputs:  Secboard("EQBR"),Account("S01-00000F00"),brokerref("009"),
	   ServerAddress("10.200.200.161"), Timeout(10000),txt("d:\testfiles\order33.txt");

vars: {secboard(" "),account(" "),brokerref(" "),seccode(" "),type(-1),}Seccode("EESR"), measure(-1.00),temp(-3),output_init(-2),
	LogMsg(0),result(0),msgnum(0),trigger(0),Yeld("P"),BuySell(""), MktLimit("M"), ImmCancel(" "),
	SplitFlag("S"), ExtRef(""), TmpOrder(""),quantity(0),det(0),price(0),attempt(1),
	fileflag(0);

defineDLLFunc: "D:\OmegaLib\1.0.0.31\niomegadll.dll", int, "conn",int;
defineDLLFunc: "D:\OmegaLib\1.0.0.31\niomegadll.dll", int, "is_conn";
defineDLLFunc: "D:\Omegalib\1.0.0.31\niomegadll.dll", int, "order",lpstr,lpstr,lpstr,lpstr,lpstr,lpstr,lpstr,double,int,lpstr,lpstr,lpstr,int,int;
defineDLLFunc: "D:\Omegalib\1.0.0.31\niomegadll.dll", int, "disconn";

if (trigger=0) then
	begin
		if (fileflag=0) then
			begin
				filedelete(txt);	
				fileflag=fileflag+1;
			end;
		result=is_conn();
		if (result=1) then
			begin
				fileappend(txt,"Let's disconnect old connection..."+newline);
				disconn();
				result=is_conn();
			end;
		fileappend(txt,"Connection message:"+numtostr(result,0)+newline);
		while (result=0) and (attempt<=50)
    		begin
	    		fileappend(txt,"connection attempt: "+numtostr(attempt,0)+newline);
	    		temp = conn(timeout);
				fileappend(txt,"conn result: "+numtostr(temp,0)+newline);
				result=is_conn();
				fileappend(txt,"Connection message after conn:"+numtostr(result,0)+newline);
				attempt=attempt+1;
    		end;
		if (result=1) then
    		begin
	   			fileappend(txt,"working..."+newline);
	   			{seccode="AAAA";}
				
				buysell="B";
       			quantity=1;
	   			price=130.43;
       			disconn();
				det=order(account, buysell, mktlimit, splitflag, immcancel, secboard, seccode, price, quantity, brokerref, extref, yeld, 118, timeout);
	   			fileappend(txt,"orderresult: "+numtostr(det,0)+newline);
				disconn();
	   			trigger=trigger+1;
	   		end;
		fileappend(txt,"---------------------------------------"+newline);
	end;
