*************
* Deck "AMWAYDeckV5.0"
*************

*************
* Global Routine(s) in deck.
*  Routine "Display Date"
*  Routine "Display Order"
*  Routine "Format $"
*  Routine "Format Fields"
*  Routine "Get Date"
*  Routine "Get Fields"
*  Routine "Get VS"
*  Routine "Quit"
*  Routine "Set Def"
*  Routine "Set Field"
*  Routine "Tax"
*************
* 11 Global routines(s), 11 were printed.
*************

*************
* Global routine "Display Date"
	SetPen A,5
	SetDrawMode JAM2 
	PrintText "Date =",Arg1,23
	PrintText "/",Arg2,23
	PrintText "/",Arg3,23
	SetPen C,5
	PrintText RightJustify(Day,2),Arg4,23
	PrintText RightJustify(Month,2),Arg5,23
	PrintText RightJustify(Year,4),Arg6,23
* End of routine "Display Date"
*************

*************
* Global routine "Display Order"
	SetPen A,5
	SetDrawMode JAM2 
	PrintText "Order No.",Arg1,23
	SetPen C,5
	PrintText CenterString(Order,1),Arg2,23
* End of routine "Display Order"
*************

*************
* Global routine "Format $"
	While ObjectState(Arg1)
		Let M=Arg2
		Let Arg3=TextFrom("."||Arg4)
		Let Arg3=Arg3||Arg5||FormatValue(N,"####0.05")
		If Arg3||Arg6||M
			Let Arg3=Arg7
			SetText "."||Arg4,FormatValue(Arg3,"####0.00")
		Else
			Delay 0,0,10
			SetText "."||Arg4,FormatValue(Arg3,"####0.00")
		EndIf
	EndLoop
* End of routine "Format $"
*************

*************
* Global routine "Format Fields"
	Let M=Max(9999)
	Let Arg2=FormatValue(TextFrom("."||Arg1),"###0.00")
	If Arg2>M
		Let Arg2=0
	EndIf
	SetText "."||Arg1,FormatValue(Arg2,"###0.00")
* End of routine "Format Fields"
*************

*************
* Global routine "Get Date"
	Let Day=GetWord(TheDate,2,"/")
	Let Month=GetWord(TheDate,1,"/")
	Let Year=GetWord(TheDate,3,"/")
* End of routine "Get Date"
*************

*************
* Global routine "Get Fields"
	Let FieldNames[1]="."||Arg1
	Let FieldNames[2]="."||Arg2
	Let FieldNames[3]="."||Arg3
	Let FieldNames[4]="."||Arg4
	Let FieldNames[5]="."||Arg5
	Let FieldNames[6]="."||Arg6
	Let FieldNames[7]="."||Arg7
* End of routine "Get Fields"
*************

*************
* Global routine "Get VS"
	If Exists("Ram:AMWAYData/StockData/Stock.Data")
		Let StockDataBase=LoadVariable("Ram:AMWAYData/StockData/Stock.Data")
	EndIf
	If Arg1<>""
		Let VS=Arg1
	Else
		Let VS=TextFrom(".VS")
	EndIf
	If VS<>""
		Local NewStockIndex
		SetSearchArrayFlags NOCASE SUBSTRING 
		Let NewStockIndex=SearchArray(StockDataBase,VS,".VS",StockIndex+1)
		If Not SearchFound
			Let NewStockIndex=SearchArray(StockDataBase,VS,".VS")
		EndIf
		If SearchFound
			Let StockIndex=NewStockIndex
		EndIf
		Let PV=FormatValue(StockDataBase[StockIndex].PV,"###0.00")
		Let BV=FormatValue(StockDataBase[StockIndex].BV,"###0.00")
		Let Dist=FormatValue(StockDataBase[StockIndex].Dist,"###0.00")
		Let Cust=FormatValue(StockDataBase[StockIndex].Cust,"###0.00")
	Else
		Let Dist=0
		Let Cust=0
	EndIf
* End of routine "Get VS"
*************

*************
* Global routine "Quit"
	If Exists("Ram:AMWAYData")
		Dos "C:Delete Ram:AMWAYData All"
	EndIf
	Dos "C:Assign AMWAYDeck: Remove"
	Quit
* End of routine "Quit"
*************

*************
* Global routine "Set Def"
	If Exists("Ram:AMWAYData/AMWAYPrefs")
		Let AMWAYPrefs=LoadVariable("Ram:AMWAYData/AMWAYPrefs")
		Let DefDate=AMWAYPrefs.Date
		Let DefNote=AMWAYPrefs.Note
		Let DefDistDir=AMWAYPrefs.Dist
		Let DefDataDir=AMWAYPrefs.Data
		Let DefOrdDir=AMWAYPrefs.Ord
		Let DefCustDir=AMWAYPrefs.Cust
		Let DefBGPic=AMWAYPrefs.BGPic
		Let DefTBGPic=AMWAYPrefs.TBGPic
		Let DefDBGPic=AMWAYPrefs.DBGPic
		Let DefOBGPic=AMWAYPrefs.OBGPic
		Let DefCBGPic=AMWAYPrefs.CBGPic
		Let DefPBGPic=AMWAYPrefs.PBGPic
		Let DefPenA=AMWAYPrefs.PenA
		Let DefPenB=AMWAYPrefs.PenB
		Let DefPenC=AMWAYPrefs.PenC
	EndIf
* End of routine "Set Def"
*************

*************
* Global routine "Set Field"
	If Arg1=""
		Let CurrField=CurrField+1
	Else
		Let CurrField=Arg1
	EndIf
	If CurrField>LastArrayIndex(FieldNames)
		Let CurrField=1
	EndIf
	SetObjectState FieldNames[CurrField],On
* End of routine "Set Field"
*************

*************
* Global routine "Tax"
	If Exists("Ram:AMWAYData/AMWAYTax")
		Let AMWAYTax=LoadVariable("Ram:AMWAYData/AMWAYTax")
		Let Tax=AMWAYTax.Tax
		Let GST=AMWAYTax.GST
		Let PST=AMWAYTax.PST
		Let VAT1=AMWAYTax.VAT1
		Let VAT2=AMWAYTax.VAT2
		If Tax<>""
			Let T="Yes"
		ElseIf GST<>""
			Let T="Yes"
		ElseIf PST<>""
			Let T="Yes"
		ElseIf VAT1<>""
			Let T="Yes"
		ElseIf VAT2<>""
			Let T="Yes"
		EndIf
	EndIf
* End of routine "Tax"
*************

