
DECLARE CONSTANT FLD_BestBidPrice		AS QUANTITY		2270
DECLARE CONSTANT FLD_BestAskPrice		AS QUANTITY		2273
DECLARE CONSTANT FLD_LastTradedPrice	AS QUANTITY		2275
DECLARE CONSTANT FLD_LastTradedSize		AS QUANTITY		2276
DECLARE CONSTANT FLD_LastTradeType		AS QUANTITY		2346
DECLARE CONSTANT FLD_AskPriceMovement	AS QUANTITY		2158
DECLARE CONSTANT FLD_BidPriceMovement	AS QUANTITY		2159
DECLARE CONSTANT FLD_NetChange			AS QUANTITY		2274

DECLARE CONSTANT FLD_Slash				AS QUANTITY		9
DECLARE CONSTANT FLD_Symbol				AS QUANTITY		10
DECLARE CONSTANT FLD_UpTick				AS QUANTITY		12
DECLARE CONSTANT FLD_DownTick			AS QUANTITY		13
DECLARE CONSTANT FLD_BidUpTick			AS QUANTITY		24
DECLARE CONSTANT FLD_BidDownTick		AS QUANTITY		23
DECLARE CONSTANT FLD_AskUpTick			AS QUANTITY		26
DECLARE CONSTANT FLD_AskDownTick		AS QUANTITY		25


PROCEDURE UpdateDisplay DO
{
	DECLARE VARIABLE	nTick				AS	QUANTITY
	DECLARE VARIABLE	fBidPriceMovement	AS	PRICE
	DECLARE VARIABLE	fAskPriceMovement	AS	PRICE
	DECLARE VARIABLE	fBestBidPrice		AS	PRICE
	DECLARE VARIABLE	fBestAskPrice		AS	PRICE
	DECLARE VARIABLE	fLastTradedPrice	AS	PRICE
	DECLARE VARIABLE	fLastTradedSize		AS	PRICE
	DECLARE VARIABLE	fNetChange			AS	PRICE
	
	
	[nTick] := GetIntFieldValueFromUnpackMsg(FLD_LastTradeType);
	[fBidPriceMovement]:= GetFloatFieldValueFromUnpackMsg(FLD_BidPriceMovement);
	[fAskPriceMovement]:= GetFloatFieldValueFromUnpackMsg(FLD_AskPriceMovement);
	[fBestBidPrice]:= GetFloatFieldValueFromUnpackMsg(FLD_BestBidPrice);
	[fBestAskPrice]:= GetFloatFieldValueFromUnpackMsg(FLD_BestAskPrice);
	[fLastTradedPrice]:= GetFloatFieldValueFromUnpackMsg(FLD_LastTradedPrice);
	[fLastTradedSize] := GetFloatFieldValueFromUnpackMsg(FLD_LastTradedSize);
	[fNetChange] := GetFloatFieldValueFromUnpackMsg(FLD_NetChange);

	# Set main Up Tick
	IF ([nTick] = 0) THEN
	{
		ShowHideCtrl(FLD_UpTick,0);
		ShowHideCtrl(FLD_DownTick,0);
	}
	ELSE IF (([nTick] = 1) OR ([nTick] = 2)) THEN	# Plus tick 
	{
		ShowHideCtrl(FLD_UpTick,1);
		ShowHideCtrl(FLD_DownTick,0);
	}
	ELSE  # minus
	{
		ShowHideCtrl(FLD_UpTick,0);
		ShowHideCtrl(FLD_DownTick,1);
	}
	
	# Set bid price movement tick
	IF ([fBidPriceMovement] > 0.0) THEN
	{
		ShowHideCtrl(FLD_BidUpTick,1);
		ShowHideCtrl(FLD_BidDownTick,0);
	}
	ELSE IF ([fBidPriceMovement] < 0.0) THEN
	{
		ShowHideCtrl(FLD_BidUpTick,0);
		ShowHideCtrl(FLD_BidDownTick,1);
	}
	ELSE
	{
		ShowHideCtrl(FLD_BidUpTick,0);
		ShowHideCtrl(FLD_BidDownTick,0);
	}
	
	# Set ask price movement tick
	IF ([fAskPriceMovement] > 0.0) THEN
	{
		ShowHideCtrl(FLD_AskUpTick,1);
		ShowHideCtrl(FLD_AskDownTick,0);
	}
	ELSE IF ([fAskPriceMovement] < 0.0) THEN
	{
		ShowHideCtrl(FLD_AskUpTick,0);
		ShowHideCtrl(FLD_AskDownTick,1);
	}
	ELSE
	{
		ShowHideCtrl(FLD_AskUpTick,0);
		ShowHideCtrl(FLD_AskDownTick,0);
	}

	# Set other direct fileds
	SetFieldValue1(FLD_BestBidPrice, FloatToString([fBestBidPrice],2));
	SetFieldValue1(FLD_BestAskPrice, FloatToString([fBestAskPrice],2));
	SetFieldValue1(FLD_LastTradedPrice, FloatToString([fLastTradedPrice],2));
	SetFieldValue1(FLD_LastTradedSize, FloatToString([fLastTradedSize],0));
	SetFieldValue1(FLD_BidPriceMovement, FloatToString([fBidPriceMovement],2));
	SetFieldValue1(FLD_AskPriceMovement, FloatToString([fAskPriceMovement],2));
	SetFieldValue1(FLD_NetChange, FloatToString([fNetChange],0));
	
	SetFieldValue1(FLD_Slash,"/");
}


PROCEDURE ClearData DO
{	
	ShowHideCtrl(FLD_UpTick,0);
	ShowHideCtrl(FLD_DownTick,0);
	ShowHideCtrl(FLD_BidUpTick,0);
	ShowHideCtrl(FLD_BidDownTick,0);
	ShowHideCtrl(FLD_AskUpTick,0);
	ShowHideCtrl(FLD_AskDownTick,0);
	
	SetFieldValue1(FLD_Symbol,"");
	SetFieldValue1(FLD_LastTradedPrice,"");
	SetFieldValue1(FLD_BestBidPrice,"");
	SetFieldValue1(FLD_BestAskPrice,"");
	SetFieldValue1(FLD_BidPriceMovement,"");
	SetFieldValue1(FLD_AskPriceMovement,"");
	SetFieldValue1(FLD_LastTradedSize,"");
	SetFieldValue1(FLD_NetChange,"");
	
	SetFieldValue1(FLD_Slash,"");
}

##########################################################
PROCEDURE SetBkgColor
		 DECLARE PARAMETER sRVal AS TEXT
		 DECLARE PARAMETER sGVal AS TEXT 
		 DECLARE PARAMETER sBVal AS TEXT DO
{
	#DECLARE VARIABLE nRed	AS QUANTITY
	#DECLARE VARIABLE nGreen	AS QUANTITY
	#DECLARE VARIABLE nBlue	AS QUANTITY
	
	#[nRed]   := StringToInt([sRVal]);
	#[nGreen] := StringToInt([sGVal]);
	#[nBlue]  := StringToInt([sBVal]);
	
	#SetBackColor([nRed], [nGreen], [nBlue], 1);
}


