Inputs: ServerAddress("10.200.200.161"), conntimeout(10000),
	   timeout(10000),txt("d:\testfiles\FutOrder2Cl.txt");

vars: secboard("PSFU"),account("AC1"),brokerref("009"),
    seccode("GAZR-12.06"),type(-1), measure(-1.00),temp(-3),output_init(-2),
	LogMsg(1),result(0),msgnum(0),trigger(0),Yeld("P"),BuySell(""), cotircontr("M"), ImmCancel(" "),
	SplitFlag("S"), ExtRef(""), TmpOrder(""),quantity(0),orderresult(-3),price(0),attempt(1);

defineDLLFunc: "D:\OmegaLib\1.0.0.30\niomegadll.dll", int, "conn",int;
defineDLLFunc: "D:\OmegaLib\1.0.0.30\niomegadll.dll", int, "is_conn";
defineDLLFunc: "D:\Omegalib\1.0.0.30\niomegadll.dll", int, "futaddorder",lpstr{seccode},lpstr{buysell},int{quantity},
	double{price},lpstr{cotircontr=mktlimit},lpstr{brokerref},lpstr{secboard},lpstr{account},int{timeout};
defineDLLFunc: "D:\OmegaLib\1.0.0.30\niomegadll.dll", int, "disconn";

if (trigger=0) then
	begin
		filedelete(txt);
		result=is_conn();
		if (result=1) then
			begin
				fileappend(txt,"Let's disconnect..."+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(conntimeout);
				fileappend(txt,"conn result: "+numtostr(temp,0)+newline);
				result=is_conn();
        		fileappend(txt,"Connection message after conn:"+numtostr(result,0)+newline);
        		fileappend(txt,"-------------------------------------------"+newline);
				attempt=attempt+1;
			end;
		if (result=1) then
    		begin
	   			fileappend(txt,"Testing order"+newline);
	   			brokerref="009";
	   			buysell="B";
       			quantity=1;
	   			price=29000;
	   			orderresult=futaddorder(seccode,buysell,quantity,price,cotircontr,brokerref,secboard,account,timeout);
	   			fileappend(txt,"orderresult: "+numtostr(orderresult,0)+newline);
	   			fileappend(txt,"-------------------------------------------"+newline);
	   			trigger=1;
				disconn();
	 		end;
	end;
