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

*************
* Card(s) in deck.
*  Card "Customer Card"
*  Card "DataBase Card"
*  Card "Distributor Card"
*  Card "Ordering Card"
*************
* 4 Card(s), 4 were printed.
*************

*************
* Natural order of Cards
*  Card "Distributor Card"
*  Card "DataBase Card"
*  Card "Ordering Card"
*  Card "Customer Card"
*************

*************
* 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.
*************

*************
* Card "Customer Card"
	NoAttach
	Routine "Tax Amounts"
		Let TaxCust=0
		Let ATX=TextFrom(".Tax")
		Let Qty=IntegerFrom(".Qty")
		Do "Format Fields","Cust",Cust
		If ATX="Tax"
			Let TaxCust=(Qty*Cust)+(Cust/100*Tax)
		ElseIf ATX="GST"
			Let TaxCust=(Qty*Cust)+(Cust/100*GST)
		ElseIf ATX="PST"
			Let TaxCust=(Qty*Cust)+(Cust/100*PST)
		ElseIf ATX="VAT1"
			Let TaxCust=(Qty*Cust)+(Cust/100*VAT1)
		ElseIf ATX="VAT2"
			Let TaxCust=(Qty*Cust)+(Cust/100*VAT1)
		ElseIf ATX<>""
			Let ATX=FormatValue(TextFrom(".Tax"),"####")
			Let TaxCust=(Qty*Cust)+(Cust/100*ATX)
		ElseIf ATX=""
			Let TaxCust=Cust
		EndIf
		SetText ".Cust",TaxCust
		Do "Format Fields","Cust",TaxCust
	EndScript
	Routine "Store Entry"
		WorkWithDocument "Cust List"
		Let Work=GetDBObjects
		If Work<>CustDataBase[CustIndex]
			Do "Delete Entry",CustIndex
			Let CustIndex=TheLineNumber
			InsertArrayEntry CustDataBase,CustIndex
			Let CustDataBase[CustIndex]=Work
		EndIf
		Do "Load DataFile"
	EndScript
	Routine "Set Tax Field"
		If Arg1
			Let TaxAmount=Arg2
			Let TaxField=Arg3
			Do "Get VS"
			SetText ".Tax",TaxField
			Do "Tax"
			Do "Tax Amounts"
			Let CustDataBase[CustIndex]=GetDBObjects
			Let SearchText=TextFrom(".VS")
			Let SearchField="VS"
			Do "Search Next"
			DoObjectScript "Enter Button",ONRELEASE 
			Do "Search Next"
		EndIf
		Do "Set Field",1
	EndScript
	Routine "Search Next"
		WorkWithDocument "Cust List"
		Local NewCustIndex
		SetSearchArrayFlags NOCASE SUBSTRING 
		Let NewCustIndex=SearchArray(CustDataBase,SearchText,"."||SearchField,CustIndex+1)
		If Not SearchFound
			Let NewCustIndex=SearchArray(CustDataBase,SearchText,"."||SearchField)
			If Not SearchFound
				If SizeOfDocument<>0
					MoveCursorTo STARTOF DOCUMENT 
					SplitLine
					MoveCursor UP 
					Let CustIndex=1
					InsertArrayEntry CustDataBase,CustIndex
					Let CustDataBase[CustIndex]=GetDBObjects
				EndIf
			EndIf
		EndIf
		If SearchFound
			Do "Get Entry",NewCustIndex
		EndIf
	EndScript
	Routine "Do Search"
		If Arg1
			SetText ".VS",Arg5.VS
			SetText ".Des",Arg5.Des
			SetText ".Tax",Arg5.Tax
			Let Cust=Arg5.Cust
			Do "Tax Amounts"
			Let StockIndex=Arg4
			Let SearchText=TextFrom(".VS")
			Let SearchField="VS"
			Do "Search Next"
			DoObjectScript "Enter Button",ONRELEASE 
			Do "Search Next"
		EndIf
	EndScript
	Routine "Delete Entry"
		DeleteArrayEntry CustDataBase,Arg1
		PositionOnLine Arg1
		If TheLineNumber=LinesInDocument
			Clear LINE 
			Delete CHARACTER ,-1
			Let CustIndex=0
		Else
			Delete LINE 
		EndIf
		Do "Load DataFile"
		PositionOnLine Arg1
	EndScript
	Routine "Print Calc Totals"
		SetDrawMode JAM2 
		If ATX="Tax"
			SetPen A,5
			PrintText "Tax=",122,300
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7),154,300
		ElseIf ATX="GST"
			SetPen A,5
			PrintText "GST=",122,300
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxCustG,DefNote||"###0.00"),7),154,300
		ElseIf ATX="PST"
			SetPen A,5
			PrintText "PST=",218,300
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxCustP,DefNote||"###0.00"),7),250,300
		ElseIf ATX="VAT1"
			SetPen A,5
			PrintText "VAT1=",122,300
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxCustV1,DefNote||"###0.00"),7),154,300
		ElseIf ATX="VAT2"
			SetPen A,5
			PrintText "VAT2=",218,300
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxCustV2,DefNote||"###0.00"),7),250,300
		ElseIf ATX<>""
			SetPen A,5
			PrintText "Tax=",122,300
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7),154,300
		ElseIf ATX=""
			SetPen A,5
			PrintText "Tax=",122,300
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7),154,300
		EndIf
	EndScript
	Routine "Print Totals"
		SetDrawMode JAM2 
		SetPrintFont "topaz",8
		SetPen B,5
		PrintText RightJustify(TotalQty,2),113,285
		PrintText RightJustify(FormatValue(TotalCust,DefNote||"###0.00"),7),378,285
	EndScript
	Routine "Totals"
		Let TotalQty=TotalQty+CustDataBase[CustIndex].Qty
		Let TotalCust=TotalCust+CustDataBase[CustIndex].Cust
		Do "Calc Tax"
	EndScript
	Routine "Get Entry"
		SetPrintFont "topaz",8
		SetDrawMode JAM2 
		SetPen B,5
		SetPrintStyle PLAIN ,B,3
		Let CustIndex=Arg1
		SetDBObjects CustDataBase[CustIndex]
		PrintText RightJustify(NumberOfArrayEntries(CustDataBase),4),350,23
		SetPen A,5
		PrintText "Customer Info...",11,23
		PrintText "There Are :",263,23
		PrintText "Items",390,23
		PrintText "Index No.",500,23
		WorkWithDocument "Cust List"
		PositionOnLine Arg1
		If DefDate="MDY"
			Do "Display Date",740,170,204,179,146,213
		Else
			Do "Display Date",740,170,204,146,179,213
		EndIf
	EndScript
	Routine "Draw Card"
		SetDrawMode JAM2 
		SetPen 0
		AreaRectangle 9,93,431,168
		SetPen 5
		AreaRectangle 7,270,456,45
		DrawBorder 7,270,456,45,BEVEL ,4,2
		SetPen A,5
		PrintText "Qty",112,275
		PrintText "Cost =",385,275
		PrintText "Customer Tax:",10,300
		SetDrawMode JAM1 
		PrintText "Ord",238,342
		PrintText "Del",370,342
	EndScript
	Routine "Load Name"
		If Exists("Ram:AMWAYData/CustData/Name.Data")
			Let CustName=LoadVariable("Ram:AMWAYData/CustData/CustName.Data")
			Do "Set Name"
		ElseIf Exists(DefCustDir||"/Cust.Data")
			Let CustName=LoadVariable(DefCustDir||"/CustName.Data")
			SaveVariable CustName,"Ram:AMWAYData/CustData/CustName.Data"
			Do "Set Name"
		ElseIf Not Exists(DefCustDir||"/CustName.Data")
			Do "Get Date"
			Let DistDataBase=LoadVariable("Ram:AMWAYData/DistData/Dist.Data")
			Let CustName.Name=DistDataBase.Name
			Let CustName.ODay=DistDataBase.Day
			Let CustName.OMonth=DistDataBase.Month
			Let CustName.OYear=DistDataBase.Year
			Let CustName.DDay=Day
			Let CustName.DMonth=Month
			Let CustName.DYear=Year
			If DefDate="MDY"
				Let CustName.DelDate=Month||"-"||Day||"-"||Year
				Let CustName.OrdDate=DistDataBase.Month||"-"||DistDataBase.Day||"-"||DistDataBase.Year
			Else
				Let CustName.DelDate=Day||"-"||Month||"-"||Year
				Let CustName.OrdDate=DistDataBase.Day||"-"||DistDataBase.Month||"-"||DistDataBase.Year
			EndIf
			SaveVariable CustName,"Ram:AMWAYData/CustData/CustName.Data"
			Do "Set Name"
		EndIf
	EndScript
	Routine "Set Name"
		Let Name=CustName.Name
		Let DDay=CustName.DDay
		Let DMonth=CustName.DMonth
		Let DYear=CustName.DYear
		Let ODay=CustName.ODay
		Let OMonth=CustName.OMonth
		Let OYear=CustName.OYear
		Let DelDate=CustName.DelDate
		Let OrdDate=CustName.OrdDate
		SetText "Name",Name
		If DefDate="MDY"
			SetText "DelDate",DelDate
			SetText "OrdDate",OrdDate
		Else
			SetText "DelDate",DelDate
			SetText "OrdDate",OrdDate
		EndIf
	EndScript
	Routine "Load DataFile"
		Do "Set Totals"
		WorkWithDocument "Cust List"
		Clear DOCUMENT 
		If Sort="Yes"
			SortArray CustDataBase,INTEGER ,".VS"
		EndIf
		Let CustIndex=FirstArrayIndex(CustDataBase)
		PrintText "                                 ",122,300
		While SearchFound
			Type LeftJustify(CustDataBase[CustIndex].VS,11)
			Type " "
			Type RightJustify(CustDataBase[CustIndex].Qty,2)
			Type " "
			Type LeftJustify(CustDataBase[CustIndex].Des,20)
			Type "  "
			If T="Yes"
				Let ATX=CustDataBase[CustIndex].Tax
				Do "Get VS",CustDataBase[CustIndex].VS
				Let Val=FormatValue(CustDataBase[CustIndex].Tax,"####")
				Type LeftJustify(FormatValue(CustDataBase[CustIndex].Tax,"###%"),4)
			Else
				Type LeftJustify(FormatValue(CustDataBase[CustIndex].Tax,"###%"),4)
			EndIf
			Type "    "
			Type RightJustify(FormatValue(CustDataBase[CustIndex].Cust,DefNote||"###0.00"),7)
			Do "Totals"
			NewLine
			Let CustIndex=NextArrayIndex(CustDataBase,CustIndex)
		EndLoop
		Delete CHARACTER ,-1
		MoveCursorTo STARTOF DOCUMENT 
		Let CustIndex=1
		Do "Print Totals"
	EndScript
	Routine "Set Totals"
		Let ATC=0
		Let TotalQty=0
		Let TotalCust=0
		Let TotalTaxCust=0
		Let TotalTaxCustT=0
		Let TotalTaxCustG=0
		Let TotalTaxCustP=0
		Let TotalTaxCustV1=0
		Let TotalTaxCustV2=0
	EndScript
	Routine "Calc Tax"
		Let Qty=IntegerFrom(".Qty")
		If ATX="Tax"
			Let TotalTaxCustT=TotalTaxCustT+(Qty*Cust/100*Val)
		ElseIf ATX="GST"
			If ATC=1
				Let ATC=2
			Else
				Let ATC=1
			EndIf
			Let TotalTaxCustG=TotalTaxCustG+(Qty*Cust/100*Val)
		ElseIf ATX="PST"
			If ATC=1
				Let ATC=2
			Else
				Let ATC=1
			EndIf
			Let TotalTaxCustP=TotalTaxCustP+(Qty*Cust/100*Val)
		ElseIf ATX="VAT1"
			If ATC=1
				Let ATC=2
			Else
				Let ATC=1
			EndIf
			Let TotalTaxCustV1=TotalTaxCustV1+(Qty*Cust/100*Val)
		ElseIf ATX="VAT2"
			If ATC=1
				Let ATC=2
			Else
				Let ATC=1
			EndIf
			Let TotalTaxCustV2=TotalTaxCustV2+(Qty*Cust/100*Val)
		ElseIf ATX<>""
			Let ATX=FormatValue(TextFrom(".Tax"),"####")
			Let TotalTaxCust=TotalTaxCust+(Qty*Cust/100*ATX)
		ElseIf ATX=""
			Let TotalTaxCust=TotalTaxCust+(Qty*Cust/100*Val)
		EndIf
		Do "Print Calc Totals"
	EndScript
	Routine "Type Calc Totals"
		If ATX="Tax"
			NewLine
			Type "Customer Tax: Tax="
			Type RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7)
		ElseIf ATX="GST"
			NewLine
			Type "Customer Tax: GST="
			Type RightJustify(FormatValue(TotalTaxCustG,DefNote||"###0.00"),7)
		ElseIf ATX="PST"
			If ATC=2
				NewLine
				Type "Customer Tax: GST="
				Type RightJustify(FormatValue(TotalTaxCustG,DefNote||"###0.00"),7)
				Type "    Customer Tax: PST="
				Type RightJustify(FormatValue(TotalTaxCustP,DefNote||"###0.00"),7)
			ElseIf ATC=1
				NewLine
				Type "    Customer Tax: PST="
				Type RightJustify(FormatValue(TotalTaxCustP,DefNote||"###0.00"),7)
			EndIf
		ElseIf ATX="VAT1"
			NewLine
			Type "Customer Tax: VAT1="
			Type RightJustify(FormatValue(TotalTaxCustV1,DefNote||"###0.00"),7)
		ElseIf ATX="VAT2"
			If ATC=2
				NewLine
				Type "Customer Tax: VAT1="
				Type RightJustify(FormatValue(TotalTaxCustV1,DefNote||"###0.00"),7)
				Type "    Customer Tax: VAT2="
				Type RightJustify(FormatValue(TotalTaxCustV2,DefNote||"###0.00"),7)
			ElseIf ATC=1
				NewLine
				Type "    Customer Tax: VAT2="
				Type RightJustify(FormatValue(TotalTaxCustV2,DefNote||"###0.00"),7)
			EndIf
		ElseIf ATX<>""
			NewLine
			Type "Customer Tax: Tax="
			Type RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7)
		ElseIf ATX=""
			NewLine
			Type "Tax="
			Type RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7)
		EndIf
	EndScript
	AfterAttachment
		Do "Set Def"
		Do "Tax"
		If DefBGPic<>""
			ShowPicture DefCBGPic
		EndIf
		Do "Draw Card"
		FastFeedBack On
		Dispose Work
		Let Sort="Yes"
		Do "Get Fields","VS","Qty","Des","Tax","Cust"
		Let FieldNames[6]="Name"
		Let FieldNames[7]="OrdDate"
		Let FieldNames[8]="DelDate"
		If Exists("Ram:AMWAYData/CustData/Cust.Data")
			Let CustDataBase=LoadVariable("Ram:AMWAYData/CustData/Cust.Data")
			Do "Load DataFile"
		ElseIf Exists(DefCustDir||"/Cust.Data")
			Let CustDataBase=LoadVariable(DefCustDir||"/Cust.Data")
			Do "Load DataFile"
			SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
		ElseIf Not Exists(DefCustDir||"/Cust.Data")
			If Exists("Ram:AMWAYData/OrderData/Order.Data")
				Let CustDataBase=LoadVariable("Ram:AMWAYData/OrderData/Order.Data")
				SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			Else
				SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
				SetFileRequestPattern "#?.Data"
				Let FileName=AskForFileName(DefCustDir||"/.Data","Select File To Load...")
				If FileOf(FileName)<>""
					Let CustDataBase=LoadVariable(FileName)
					Do "Load DataFile"
					SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
				Else
					Let CustIndex=1
					Let CustDataBase[CustIndex]=GetDBObjects
					Do "Load DataFile"
					SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
				EndIf
			EndIf
		EndIf
		Do "Load Name"
		Do "Tax Amounts"
		Let StockIndex=Arg4
		Let SearchText=TextFrom(".VS")
		Let SearchField="VS"
		Do "Search Next"
		DoObjectScript "Enter Button",ONRELEASE 
		Do "Search Next"
		Do "Get Date"
		Do "Get Entry",1
		Do "Set Field",1
	EndScript
	MessageFromSubDeck
		If Arg1<>""
			Do Arg1,Alias("Arg2"),Alias("Arg3"),Alias("Arg4"),Alias("Arg5"),Alias("Arg6")
		EndIf
	EndScript
	Routine "PrintTax"
		Do "Get Date"
		Let Name=TextFrom("Name")
		Let DelDate=TextFrom("DelDate")
		Let Orddate=TextFrom("OrdDate")
		WorkWithDocument "Ram:AMWAYData/CustData/Cust.Doc"
		Clear DOCUMENT 
		Type "           Customer Receipt",NEWLINE 
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
		Type "Distributor Name:",NEWLINE 
		Type DistDataBase.Name,NEWLINE 
		NewLine
		Type "VS          Qty Description         Tax         Cost"
		MoveCursorTo ENDOF DOCUMENT 
		NewLine
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
		InsertDocument "Cust List"
		MoveCursorTo ENDOF DOCUMENT 
		NewLine
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
		Type "      Total Qty                           Total Cost",NEWLINE 
		Type "            "
		Type RightJustify(TotalQty,2)
		Type "                               "
		Type RightJustify(FormatValue(TotalCust,DefNote||"###0.00"),7)
		Do "Type Calc Totals"
		NewLine
		NewLine
		Type "Customers Name:               Date of Order "||OrdDate,NEWLINE 
		Type Name,NEWLINE 
		NewLine
		Type "                              Delivery Date "||DelDate,NEWLINE 
		Type "Distributor Signature:",NEWLINE 
		NewLine
		NewLine
		Type "­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­",NEWLINE 
	EndScript
	Window "UserWindow"
		Definition
			Origin 0,12
			Title "Customer Screen..."
			WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR 
			Size 471,365
			DefaultColors 1,0,5
			WindowFlags ACTIVATE TOFRONT WORKBENCH 
			VisualEffects NONE ,WAIT 
		EndScript
		OnCloseButton
			Let CustDataBase[CustIndex]=GetDBObjects
			SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			GotoCard "Ordering Card"
		EndScript
	EndObject
	List "CustDoc"
		Definition
			ListDocument "Cust List" ; where the text comes from
			Origin 9,93
			Size 452,168
			Border INVERT BEVEL  ; BorderStyle, MainPen, ExtraPen
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,0,JAM1  ; PenA, PenB, DrawMode
			Style PLAIN ,2,1
		EndScript
		OnRelease
			WorkWithDocument "Cust List"
			Do "Get Entry",TheLineNumber
			Do "Set Field",CurrField
		EndScript
	EndObject
	TextMenu "New"
		Definition
			AttachTo MENU ,"Project..."
			Text "New..."
			ShortCutKey "N"
		EndScript
		Occurred
			DoObjectScript "New Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Load"
		Definition
			AttachTo MENU ,"Project..."
			Text "Load..."
			ShortCutKey "L"
		EndScript
		Occurred
			DoObjectScript "Load Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Save"
		Definition
			AttachTo MENU ,"Project..."
			Text "Save..."
			ShortCutKey "S"
		EndScript
		Occurred
			DoObjectScript "Save Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Save As"
		Definition
			AttachTo MENU ,"Project..."
			Text "Save As..."
			ShortCutKey "A"
		EndScript
		Occurred
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefCustDir||"/Cust.Data","Select File To Load...")
			If FileOf(FileName)<>Nothing
				SaveVariable CustDataBase,FileName
				SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			Else
				Let CustDataBase[CustIndex]=GetDBObjects
			EndIf
		EndScript
	EndObject
	TextMenu "Previous"
		Definition
			AttachTo MENU ,"Project..."
			Text "Previous..."
			ShortCutKey "<"
		EndScript
		Occurred
			DoObjectScript "Previous Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Next"
		Definition
			AttachTo MENU ,"Project..."
			Text "Next..."
			ShortCutKey ">"
		EndScript
		Occurred
			DoObjectScript "Next Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Delete"
		Definition
			AttachTo MENU ,"Project..."
			Text "Delete..."
			ShortCutKey "D"
		EndScript
		Occurred
			DoObjectScript "Delete Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Find"
		Definition
			AttachTo MENU ,"Project..."
			Text "Find..."
			ShortCutKey "F"
		EndScript
		Occurred
			DoObjectScript "Search Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Distributor"
		Definition
			AttachTo MENU ,"Project..."
			Text "Distributor..."
			ShortCutKey "T"
		EndScript
		Occurred
			Let CustDataBase[CustIndex]=GetDBObjects
			SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			GotoCard "Distributor Card"
		EndScript
	EndObject
	TextMenu "DataBase"
		Definition
			AttachTo MENU ,"Project..."
			Text "DataBase..."
			ShortCutKey "B"
		EndScript
		Occurred
			Let CustDataBase[CustIndex]=GetDBObjects
			SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			GotoCard "DataBase Card"
		EndScript
	EndObject
	TextMenu "Ordering"
		Definition
			AttachTo MENU ,"Project..."
			Text "Ordering..."
			ShortCutKey "O"
		EndScript
		Occurred
			Let CustDataBase[CustIndex]=GetDBObjects
			SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			GotoCard "Ordering Card"
		EndScript
	EndObject
	TextMenu "Print"
		Definition
			AttachTo MENU ,"Project..."
			Text "Print..."
			ShortCutKey "P"
		EndScript
		Occurred
			SaveDocument "Stock List","Ram:AMWAYData/PrintData/Stock.list"
			Dos "C:Copy Ram:AMWAYData/PrintData/Stock.list PRT:"
		EndScript
	EndObject
	TextMenu "Quit"
		Definition
			AttachTo MENU ,"Project..."
			Text "Quit..."
			ShortCutKey "Q"
		EndScript
		Occurred
			Do "Quit"
		EndScript
	EndObject
	TextField ".VS"
		Definition
			InitialText ""
			Origin 9,73
			Size 88,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 11
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=1
		EndScript
		OnRelease
			Let VS=TextFrom(".VS")
			Do "Set Field",3
		EndScript
	EndObject
	IntegerField ".Qty"
		Definition
			Limits 1,99
			InitialInteger 1
			Origin 103,73
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 2
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnRelease
			Do "Get VS"
			Let Qty=IntegerFrom(".Qty")
			Let PV=FormatValue(Qty*StockDataBase[StockIndex].PV,"###0.00")
			Let BV=FormatValue(Qty*StockDataBase[StockIndex].BV,"###0.00")
			Let Dist=FormatValue(Qty*StockDataBase[StockIndex].Dist,"###0.00")
			Let Cust=FormatValue(Qty*StockDataBase[StockIndex].Cust,"###0.00")
			SetText ".PV",PV
			SetText ".BV",BV
			SetText ".Dist",Dist
			SetText ".Cust",Cust
			Do "Set Field",3
		EndScript
		OnClick
			Let CurrField=2
		EndScript
	EndObject
	TextField ".Des"
		Definition
			InitialText ""
			Origin 133,73
			Size 160,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 20
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnRelease
			Let Des=TextFrom(".Des")
			Do "Set Field",4
		EndScript
		OnClick
			Let CurrField=3
		EndScript
	EndObject
	TextField ".Tax"
		Definition
			InitialText ""
			Origin 299,73
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 4
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=6
		EndScript
		OnRelease
			Do "Set Field",5
		EndScript
	EndObject
	TextField ".Cust"
		Definition
			InitialText ""
			Origin 369,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=5
		EndScript
		OnRelease
			Do "Format Fields","Cust",Cust
			Let Entry=GetDBObjects
			If Entry<>OrderDataBase[OrderIndex]
				Let SearchText=TextFrom(".VS")
				Let SearchField="VS"
				DoObjectScript "Enter Button",ONRELEASE 
				Do "Search Next"
			EndIf
			Do "Set Field",6
		EndScript
	EndObject
	AreaButton "Info BarA"
		Definition
			Origin 7,20
			Image "AMWAYDeck:AMWAY.br/BarA.br"
			Highlight NONE 
		EndScript
	EndObject
	AreaButton "Info BarB"
		Definition
			Origin 127,20
			Image "AMWAYDeck:AMWAY.br/BarB.br"
			Highlight NONE 
		EndScript
	EndObject
	AreaButton "New Button"
		Definition
			Origin 7,37
			Image "AMWAYDeck:AMWAY.br/New.b0"
			AltImage "AMWAYDeck:AMWAY.br/New.b1"
		EndScript
		OnRelease
			SetDBObjects Nothing
			WorkWithDocument "Cust List"
			Clear DOCUMENT 
			Dispose CustDataBase
			Let CustDataBase[CustIndex]=GetDBObjects
			Do "Load DataFile"
			Do "Get Entry",1
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Previous Button"
		Definition
			Origin 45,37
			Image "AMWAYDeck:AMWAY.br/Prev.b0"
			AltImage "AMWAYDeck:AMWAY.br/Prev.b1"
		EndScript
		OnRelease
			Let Entry=GetDBObjects
			If Entry<>CustDataBase[CustIndex]
				DoObjectScript "Enter Button",ONRELEASE 
			EndIf
			Let CustIndex=PreviousArrayIndex(CustDataBase,CustIndex)
			If Not SearchFound
				Let CustIndex=LastArrayIndex(CustDataBase)
			EndIf
			Do "Get Entry",CustIndex
		EndScript
	EndObject
	AreaButton "Next Button"
		Definition
			Origin 152,37
			Image "AMWAYDeck:AMWAY.br/Next.b0"
			AltImage "AMWAYDeck:AMWAY.br/Next.b1"
		EndScript
		OnRelease
			Let Entry=GetDBObjects
			If Entry<>CustDataBase[CustIndex]
				DoObjectScript "Enter Button",ONRELEASE 
			EndIf
			Let CustIndex=NextArrayIndex(CustDataBase,CustIndex)
			If Not SearchFound
				Let CustIndex=FirstArrayIndex(CustDataBase)
			EndIf
			Do "Get Entry",CustIndex
		EndScript
	EndObject
	AreaButton "Load Button"
		Definition
			Origin 227,37
			Image "AMWAYDeck:AMWAY.br/Load.b0"
			AltImage "AMWAYDeck:AMWAY.br/Load.b1"
		EndScript
		OnRelease
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefCustDir||"/.Data","Select File To Load...")
			If FileOf(FileName)<>""
				Let CustDataBase=LoadVariable(FileName)
				Do "Load DataFile"
				SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			Else
				Let CustIndex=1
				Let CustDataBase[CustIndex]=GetDBObjects
				Do "Load DataFile"
				SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			EndIf
			Do "Get Date"
			Do "Get Entry",1
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Save Button"
		Definition
			Origin 297,37
			Image "AMWAYDeck:AMWAY.br/Save.b0"
			AltImage "AMWAYDeck:AMWAY.br/Save.b1"
		EndScript
		OnRelease
			Let CustDataBase[CustIndex]=GetDBObjects
			SortArray CustDataBase,INTEGER ,".VS"
			SaveVariable CustDataBase,DefCustDir||"/Cust.Data"
			SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			If DefDate="MDY"
				SaveVariable CustDataBase,DefCustDir||"/Cust-["||Month||"-"||Day||"-"||Year||"].Data"
				SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust-["||Month||"-"||Day||"-"||Year||"].Data"
			Else
				SaveVariable CustDataBase,DefCustDir||"/Cust-["||Day||"-"||Month||"-"||Year||"].Data"
				SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust-["||Day||"-"||Month||"-"||Year||"].Data"
			EndIf
			Let CustName.Name=TextFrom("Name")
			Let CustName.OrdDate=TextFrom("OrdDate")
			Let CustName.DelDate=TextFrom("DelDate")
			Let CustName.DDay=Day
			Let CustName.DMonth=Month
			Let CustName.DYear=Year
			Let CustName.ODay=ODay
			Let CustName.OMonth=OMonth
			Let CustName.OYear=OYear
			SaveVariable CustName,"Ram:AMWAYData/CustData/CustName.Data"
			SaveVariable CustName,"Ram:AMWAYData/CustData/"||CustName.Name||".Data"
			SaveVariable CustName,DefCustDir||"/CustName.Data"
			SaveVariable CustName,DefCustDir||"/"||CustName.Name||".Data"
		EndScript
	EndObject
	AreaButton "Delete Button"
		Definition
			Origin 367,37
			Image "AMWAYDeck:AMWAY.br/Del.b0"
			AltImage "AMWAYDeck:AMWAY.br/Del.b1"
		EndScript
		OnRelease
			WorkWithDocument "Cust List"
			If LinesInDocument=>1
				Do "Delete Entry",TheLineNumber
				Do "Get Entry",TheLineNumber
			EndIf
			Let CustDataBase[CustIndex]=GetDBObjects
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Ordering Button"
		Definition
			Origin 295,319
			Image "AMWAYDeck:AMWAY.br/Ord.b0"
			AltImage "AMWAYDeck:AMWAY.br/Ord.b1"
		EndScript
		OnRelease
			Let CustDataBase[CustIndex]=GetDBObjects
			SaveVariable CustDataBase,"Ram:AMWAYData/CustData/Cust.Data"
			GotoCard "Ordering Card"
		EndScript
	EndObject
	AreaButton "Enter Button"
		Definition
			Origin 0,0
			Highlight NONE 
			Size 1,1
		EndScript
		OnRelease
			WorkWithDocument "Cust List"
			Let L=TheLineNumber
			Do "Store Entry"
			Do "Get Entry",L
			Do "Set Field",CurrField
		EndScript
	EndObject
	AreaButton "Print Button"
		Definition
			Origin 437,37
			Image "AMWAYDeck:AMWAY.br/Prt.b0"
			AltImage "AMWAYDeck:AMWAY.br/Prt.b1"
		EndScript
		OnRelease
			If T="Yes"
				Do "PrintTax"
			Else
				Do "Get Date"
				Let Name=TextFrom("Name")
				Let DelDate=TextFrom("DelDate")
				Let Orddate=TextFrom("OrdDate")
				WorkWithDocument "Ram:AMWAYData/CustData/Cust.Doc"
				Clear DOCUMENT 
				Type "           Customer Receipt",NEWLINE 
				Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
				Type "Distributor Name:",NEWLINE 
				Type DistDataBase.Name,NEWLINE 
				NewLine
				Type "VS      Qty    Description             Cost"
				MoveCursorTo ENDOF DOCUMENT 
				NewLine
				Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
				InsertDocument "Cust List"
				MoveCursorTo ENDOF DOCUMENT 
				NewLine
				Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
				Type "  Total Qty                      Total Cost",NEWLINE 
				Type "        "
				Type CenterString(TotalQty,3)
				Type "                        "
				Type RightJustify(FormatValue(TotalCust,DefNote||"###0.00"),7)
				NewLine
				NewLine
				Type "Customers Name:      Date of Order "||OrdDate,NEWLINE 
				Type Name,NEWLINE 
				NewLine
				Type "                     Delivery Date "||DelDate,NEWLINE 
			EndIf
			SaveDocument "Ram:AMWAYData/CustData/Cust.Doc"
			SaveDocument "Ram:AMWAYData/CustData/Cust.Doc","Ram:AMWAYData/PrintData/CustPrint.Doc"
			Dos "C:Rename Ram:AMWAYData/CustData/Cust.Doc Ram:AMWAYData/CustData/CustOrder-"||Order||"-["||OrdDate||"].Doc"
			Dos "C:Delete Ram:AMWAYData/CustData/Cust.Doc"
			Dos "C:Copy Ram:AMWAYData/CustData "||DefCustDir||"/ All"
			Dos "C:Copy Ram:AMWAYData/PrintData/CustPrint.Doc Prt:"
		EndScript
	EndObject
	AreaButton "VS Button"
		Definition
			Origin 7,55
			Image "AMWAYDeck:AMWAY.br/VS.b0"
			AltImage "AMWAYDeck:AMWAY.br/VS.b1"
		EndScript
		OnRelease
			SetText ".VS",""
			SetObjectState ".VS",On
		EndScript
	EndObject
	AreaButton "Search Button"
		Definition
			Origin 44,55
			Image "AMWAYDeck:AMWAY.br/Ser.b0"
			AltImage "AMWAYDeck:AMWAY.br/Ser.b1"
		EndScript
		OnRelease
			OpenWindow "AMWAYSubDeck","List Stock","Do Search",SearchText,SearchField
		EndScript
	EndObject
	AreaButton "Qty + Button"
		Definition
			Origin 100,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Get VS"
			Do "Tax"
			Do "Tax Amounts"
			Let OrderDataBase[OrderIndex]=GetDBObjects
			Let SearchText=TextFrom(".VS")
			Let SearchField="VS"
			Do "Search Next"
			DoObjectScript "Enter Button",ONRELEASE 
			Do "Search Next"
			Do "Set Field",2
		EndScript
		OnClick
			Do "Get VS"
			While ObjectState("Qty + Button")
				Let Qty=IntegerFrom(".Qty")
				Let Qty=Qty+1
				If Qty>99
					Let Qty=1
				EndIf
				Let PV=FormatValue(Qty*StockDataBase[StockIndex].PV,"###0.00")
				Let BV=FormatValue(Qty*StockDataBase[StockIndex].BV,"###0.00")
				Let Dist=FormatValue(Qty*StockDataBase[StockIndex].Dist,"###0.00")
				Let Cust=FormatValue(Qty*StockDataBase[StockIndex].Cust,"###0.00")
				Delay 0,0,10
				SetInteger ".Qty",Qty
				SetText ".PV",PV
				SetText ".BV",BV
				SetText ".Dist",Dist
				SetText ".Cust",Cust
			EndLoop
		EndScript
	EndObject
	AreaButton "Qty - Button"
		Definition
			Origin 115,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			DoObjectScript "Qty + Button",ONRELEASE 
		EndScript
		OnClick
			Do "Get VS"
			While ObjectState("Qty - Button")
				Let Qty=IntegerFrom(".Qty")
				Let Qty=Qty-1
				If Qty=0
					Let Qty=99
				EndIf
				Let PV=FormatValue(Qty*StockDataBase[StockIndex].PV,"###0.00")
				Let BV=FormatValue(Qty*StockDataBase[StockIndex].BV,"###0.00")
				Let Dist=FormatValue(Qty*StockDataBase[StockIndex].Dist,"###0.00")
				Let Cust=FormatValue(Qty*StockDataBase[StockIndex].Cust,"###0.00")
				Delay 0,0,10
				SetInteger ".Qty",Qty
				SetText ".PV",PV
				SetText ".BV",BV
				SetText ".Dist",Dist
				SetText ".Cust",Cust
			EndLoop
		EndScript
	EndObject
	AreaButton "Des Button"
		Definition
			Origin 131,55
			Image "AMWAYDeck:AMWAY.br/Des.b0"
			AltImage "AMWAYDeck:AMWAY.br/Des.b1"
		EndScript
		OnRelease
			SetText ".Des",""
			Do "Set Field",3
		EndScript
	EndObject
	AreaButton "Tax Button"
		Definition
			Origin 297,55
			Image "AMWAYDeck:AMWAY.br/Tax.b0"
			AltImage "AMWAYDeck:AMWAY.br/Tax.b1"
		EndScript
		OnRelease
			OpenWindow "AMWAYSubDeck","Tax Card","Set Tax Field",SearchText,SearchField
		EndScript
	EndObject
	AreaButton "Cust + Button"
		Definition
			Origin 367,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnClick
			Do "Format $","Cust + Button",Max(99999),Cust,"Cust","+",">",0
		EndScript
		OnRelease
			Do "Set Field",8
		EndScript
	EndObject
	AreaButton "Cust Button"
		Definition
			Origin 381,55
			Image "AMWAYDeck:AMWAY.br/Cost.b0"
			AltImage "AMWAYDeck:AMWAY.br/Cost.b1"
		EndScript
		OnRelease
			SetText ".Cust",""
			Do "Set Field",8
		EndScript
	EndObject
	AreaButton "Cust - Button"
		Definition
			Origin 420,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnClick
			Do "Format $","Cust - Button",Min(0),Cust,"Cust","-","<",99999
		EndScript
		OnRelease
			Do "Set Field",8
		EndScript
	EndObject
	TextField "Name"
		Definition
			InitialText ""
			Origin 9,339
			Size 208,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 25
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=5
		EndScript
		OnRelease
			Let Name=TextFrom("Name")
			Do "Set Field",7
		EndScript
	EndObject
	TextField "OrdDate"
		Definition
			InitialText ""
			Origin 266,339
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 12
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=7
		EndScript
		OnRelease
			Let OrdDate=TextFrom("OrdDate")
			Do "Set Field",8
			
		EndScript
	EndObject
	TextField "DelDate"
		Definition
			InitialText ""
			Origin 397,339
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 12
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=8
		EndScript
		OnRelease
			Let DelDate=TextFrom("DelDate")
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Name Button"
		Definition
			Origin 7,319
			Image "AMWAYDeck:AMWAY.br/Name.b0"
			AltImage "AMWAYDeck:AMWAY.br/Name.b1"
		EndScript
		OnRelease
			SetText ".Name",""
			Do "Display Number"
		EndScript
	EndObject
* End of Card "Customer Card"
*************

*************
* Card "DataBase Card"
	NoAttach
	AfterAttachment
		Do "Set Def"
		Do "Tax"
		If DefBGPic<>""
			ShowPicture DefDBGPic
		EndIf
		SetDrawMode JAM2 
		SetPen 0
		AreaRectangle 9,93,601,168
		FastFeedBack On
		Dispose Work
		Let Sort="Yes"
		Do "Get Fields","VS","Qty","Des","PV","BV","Tax","Dist"
		Let FieldNames[8]=".Cust"
		If Exists("Ram:AMWAYData/StockData/Stock.Data")
			Let StockDataBase=LoadVariable("Ram:AMWAYData/StockData/Stock.Data")
			Do "Load DataFile"
		ElseIf Exists(DefDataDir||"/Stock.Data")
			Let StockDataBase=LoadVariable(DefDataDir||"/Stock.Data")
			Do "Load DataFile"
			SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
		ElseIf Not Exists(DefDataDir||"/Stock.Data")
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefDataDir||"/.Data","Select File To Load...")
			If FileOf(FileName)<>""
				Let StockDataBase=LoadVariable(FileName)
				Do "Load DataFile"
				SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			Else
				Let StockIndex=1
				Let StockDataBase[StockIndex]=GetDBObjects
				Do "Load DataFile"
				SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			EndIf
		EndIf
		Do "Get Date"
		Do "Get Entry",1
		Do "Set Field",1
	EndScript
	MessageFromSubDeck
		If Arg1<>""
			Do Arg1,Alias("Arg2"),Alias("Arg3"),Alias("Arg4")
		EndIf
	EndScript
	Routine "Do Search"
		If Arg1
			Let SearchText=Arg2
			Let SearchField=Arg3
			Do "Search Next"
		EndIf
		Do "Set Field",1
	EndScript
	Routine "Delete Entry"
		DeleteArrayEntry StockDataBase,Arg1
		PositionOnLine Arg1
		If TheLineNumber=LinesInDocument
			Clear LINE 
			Delete CHARACTER ,-1
			Let StockIndex=0
		Else
			Delete LINE 
		EndIf
	EndScript
	Routine "Search Next"
		Local NewStockIndex
		SetSearchArrayFlags NOCASE FORWARD SUBSTRING 
		Let NewStockIndex=SearchArray(StockDataBase,SearchText,"."||SearchField,StockIndex+1)
		If Not SearchFound
			Let NewStockIndex=SearchArray(StockDataBase,SearchText,"."||SearchField)
		EndIf
		If SearchFound
			Do "Get Entry",NewStockIndex
		EndIf
	EndScript
	Routine "Set Tax Field"
		If Arg1
			Let TaxAmount=Arg2
			Let TaxField=Arg3
			SetText ".Tax",TaxField
			Do "Tax"
			DoObjectScript "Enter Button",ONRELEASE 
		EndIf
		Do "Set Field",1
	EndScript
	Routine "Store Entry"
		WorkWithDocument "Stock List"
		Let Work=GetDBObjects
		If Work<>StockDataBase[StockIndex]
			Do "Delete Entry",StockIndex
			Let StockIndex=TheLineNumber
			InsertArrayEntry StockDataBase,StockIndex
			Let StockDataBase[StockIndex]=Work
		EndIf
		Do "Load DataFile"
	EndScript
	Routine "Get Entry"
		SetPrintFont "topaz",8
		SetDrawMode JAM2 
		SetPen B,5
		SetPrintStyle PLAIN ,B,3
		Let StockIndex=Arg1
		SetDBObjects StockDataBase[StockIndex]
		PrintText RightJustify(StockIndex,4),570,23
		PrintText RightJustify(NumberOfArrayEntries(StockDataBase),4),380,23
		SetPen A,5
		PrintText "DataBase Info...",11,23
		PrintText "There Are :",293,23
		PrintText "Items",420,23
		PrintText "Index No.",500,23
		WorkWithDocument "Stock List"
		PositionOnLine Arg1
		If DefDate="MDY"
			Do "Display Date",740,200,234,209,176,243
		Else
			Do "Display Date",740,200,234,176,209,243
		EndIf
	EndScript
	Routine "Load DataFile"
		WorkWithDocument "Stock List"
		Clear DOCUMENT 
		If Sort="Yes"
			SortArray StockDataBase,INTEGER ,".VS"
		EndIf
		Let StockIndex=FirstArrayIndex(StockDataBase)
		While SearchFound
			Type LeftJustify(StockDataBase[StockIndex].VS,11)
			Type " "
			Type RightJustify(StockDataBase[StockIndex].Qty,2)
			Type " "
			Type LeftJustify(StockDataBase[StockIndex].Des,20)
			Type "  "
			Type RightJustify(FormatValue(StockDataBase[StockIndex].PV,"###0.00"),7)
			Type "  "
			Type RightJustify(FormatValue(StockDataBase[StockIndex].BV,"###0.00"),7)
			Type " "
			If T="Yes"
				Type LeftJustify(FormatValue(StockDataBase[StockIndex].Tax,"###%"),4)
			Else
				Type LeftJustify(FormatValue(StockDataBase[StockIndex].Tax,"###%"),4)
			EndIf
			Type " "
			Type RightJustify(FormatValue(StockDataBase[StockIndex].Dist,DefNote||"###0.00"),7)
			Type " "
			Type RightJustify(FormatValue(StockDataBase[StockIndex].Cust,DefNote||"###0.00"),7)
			NewLine
			Let StockIndex=NextArrayIndex(StockDataBase,StockIndex)
		EndLoop
		Delete CHARACTER ,-1
		MoveCursorTo STARTOF DOCUMENT 
		Let StockIndex=1
	EndScript
	Window "UserWindow"
		Definition
			Origin 0,12
			Title "DataBase Screen..."
			WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR 
			Size 640,280
			DefaultColors 1,0,5
			WindowFlags ACTIVATE TOFRONT WORKBENCH 
			VisualEffects NONE ,WAIT 
		EndScript
		OnCloseButton
			Let StockDataBase[StockIndex]=GetDBObjects
			SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			GotoCard "Distributor Card"
		EndScript
	EndObject
	AreaButton "Info BarA"
		Definition
			Origin 7,20
			Image "AMWAYDeck:AMWAY.br/BarA.br"
			Highlight NONE 
		EndScript
	EndObject
	AreaButton "Info BarB"
		Definition
			Origin 297,20
			Image "AMWAYDeck:AMWAY.br/BarB.br"
			Highlight NONE 
		EndScript
	EndObject
	AreaButton "New Button"
		Definition
			Origin 7,37
			Image "AMWAYDeck:AMWAY.br/New.b0"
			AltImage "AMWAYDeck:AMWAY.br/New.b1"
		EndScript
		OnRelease
			Do "Store Entry"
			SetDBObjects Nothing
			Let StockIndex=1
			Let VS=TextFrom(".VS")
			WorkWithDocument "Stock List"
			If VS<>StockDataBase[StockIndex].VS
				If SizeOfDocument<>0
					MoveCursorTo STARTOF DOCUMENT 
					SplitLine
					MoveCursor UP 
					Let StockIndex=1
					InsertArrayEntry StockDataBase,StockIndex
				EndIf
			EndIf
			Let StockDataBase[StockIndex]=GetDBObjects
			Let Sort=""
			Do "Load DataFile"
			Do "Get Entry",1
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Previous Button"
		Definition
			Origin 45,37
			Image "AMWAYDeck:AMWAY.br/Prev.b0"
			AltImage "AMWAYDeck:AMWAY.br/Prev.b1"
		EndScript
		OnRelease
			Let Entry=GetDBObjects
			If Entry<>StockDataBase[StockIndex]
				DoObjectScript "Enter Button",ONRELEASE 
			EndIf
			Let StockIndex=PreviousArrayIndex(StockDataBase,StockIndex)
			If Not SearchFound
				Let StockIndex=LastArrayIndex(StockDataBase)
			EndIf
			Do "Get Entry",StockIndex
		EndScript
	EndObject
	AreaButton "Next Button"
		Definition
			Origin 152,37
			Image "AMWAYDeck:AMWAY.br/Next.b0"
			AltImage "AMWAYDeck:AMWAY.br/Next.b1"
		EndScript
		OnRelease
			Let Entry=GetDBObjects
			If Entry<>StockDataBase[StockIndex]
				DoObjectScript "Enter Button",ONRELEASE 
			EndIf
			Let StockIndex=NextArrayIndex(StockDataBase,StockIndex)
			If Not SearchFound
				Let StockIndex=FirstArrayIndex(StockDataBase)
			EndIf
			Do "Get Entry",StockIndex
		EndScript
	EndObject
	AreaButton "Load Button"
		Definition
			Origin 227,37
			Image "AMWAYDeck:AMWAY.br/Load.b0"
			AltImage "AMWAYDeck:AMWAY.br/Load.b1"
		EndScript
		OnRelease
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefDataDir||"/.Data","Select File To Load...")
			If FileOf(FileName)<>""
				Let StockDataBase=LoadVariable(FileName)
				Do "Load DataFile"
				SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			Else
				Let StockIndex=1
				Let StockDataBase[StockIndex]=GetDBObjects
				Do "Load DataFile"
				SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			EndIf
			Do "Get Date"
			Do "Get Entry",1
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Save Button"
		Definition
			Origin 297,37
			Image "AMWAYDeck:AMWAY.br/Save.b0"
			AltImage "AMWAYDeck:AMWAY.br/Save.b1"
		EndScript
		OnRelease
			Let StockDataBase[StockIndex]=GetDBObjects
			SortArray StockDataBase,INTEGER ,".VS"
			SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			SaveVariable StockDataBase,DefDataDir||"/Stock.Data"
		EndScript
	EndObject
	AreaButton "Delete Button"
		Definition
			Origin 367,37
			Image "AMWAYDeck:AMWAY.br/Del.b0"
			AltImage "AMWAYDeck:AMWAY.br/Del.b1"
		EndScript
		OnRelease
			WorkWithDocument "Stock List"
			If LinesInDocument=>1
				Do "Delete Entry",TheLineNumber
				Do "Get Entry",TheLineNumber
			EndIf
			Let StockDataBase[StockIndex]=GetDBObjects
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Order Button"
		Definition
			Origin 437,37
			Image "AMWAYDeck:AMWAY.br/Ord.b0"
			AltImage "AMWAYDeck:AMWAY.br/Ord.b1"
		EndScript
		OnRelease
			Let StockDataBase[StockIndex]=GetDBObjects
			SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			GotoCard "Ordering Card"
		EndScript
	EndObject
	AreaButton "Enter Button"
		Definition
			Origin 607,37
			Image "AMWAYDeck:AMWAY.br/Ent.b0"
			AltImage "AMWAYDeck:AMWAY.br/Ent.b1"
		EndScript
		OnRelease
			WorkWithDocument "Stock List"
			Let L=TheLineNumber
			Do "Store Entry"
			Do "Get Entry",L
			Do "Set Field",CurrField
		EndScript
	EndObject
	AreaButton "VS Button"
		Definition
			Origin 7,55
			Image "AMWAYDeck:AMWAY.br/VS.b0"
			AltImage "AMWAYDeck:AMWAY.br/VS.b1"
		EndScript
		OnRelease
			SetText ".VS",""
			SetObjectState ".VS",On
		EndScript
	EndObject
	AreaButton "Search Button"
		Definition
			Origin 44,55
			Image "AMWAYDeck:AMWAY.br/Ser.b0"
			AltImage "AMWAYDeck:AMWAY.br/Ser.b1"
		EndScript
		OnRelease
			OpenWindow "AMWAYSubDeck","Stock Search","Do Search",SearchText,SearchField
		EndScript
	EndObject
	AreaButton "Qty Button"
		Definition
			Origin 101,55
			Image "AMWAYDeck:AMWAY.br/N.b0"
			AltImage "AMWAYDeck:AMWAY.br/N.b1"
		EndScript
		OnRelease
			SetInteger ".Qty",1
			Do "Set Field",2
		EndScript
	EndObject
	AreaButton "Des Button"
		Definition
			Origin 131,55
			Image "AMWAYDeck:AMWAY.br/Des.b0"
			AltImage "AMWAYDeck:AMWAY.br/Des.b1"
		EndScript
		OnRelease
			SetText ".Des",""
			Do "Set Field",3
		EndScript
	EndObject
	AreaButton "PV + Button"
		Definition
			Origin 297,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Set Field",4
		EndScript
		OnClick
			Do "Format $","PV + Button",Max(99999),PV,"PV","+",">",0
		EndScript
	EndObject
	AreaButton "PV Button"
		Definition
			Origin 311,55
			Image "AMWAYDeck:AMWAY.br/PV.b0"
			AltImage "AMWAYDeck:AMWAY.br/PV.b1"
		EndScript
		OnRelease
			SetText ".PV",""
			Do "Set Field",4
		EndScript
	EndObject
	AreaButton "PV - Button"
		Definition
			Origin 350,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			Do "Set Field",4
		EndScript
		OnClick
			Do "Format $","PV - Button",Min(0),PV,"PV","-","<",99999
		EndScript
	EndObject
	AreaButton "BV + Button"
		Definition
			Origin 367,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Set Field",5
		EndScript
		OnClick
			Do "Format $","BV + Button",Max(99999),BV,"BV","+",">",0
		EndScript
	EndObject
	AreaButton "BV Button"
		Definition
			Origin 381,55
			Image "AMWAYDeck:AMWAY.br/BV.b0"
			AltImage "AMWAYDeck:AMWAY.br/BV.b1"
		EndScript
		OnRelease
			SetText ".BV",""
			Do "Set Field",5
		EndScript
	EndObject
	AreaButton "BV - Button"
		Definition
			Origin 420,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			Do "Set Field",5
		EndScript
		OnClick
			Do "Format $","BV - Button",Min(0),BV,"BV","-","<",99999
		EndScript
	EndObject
	AreaButton "Tax Button"
		Definition
			Origin 437,55
			Image "AMWAYDeck:AMWAY.br/Tax.b0"
			AltImage "AMWAYDeck:AMWAY.br/Tax.b1"
		EndScript
		OnRelease
			OpenWindow "AMWAYSubDeck","Tax Card","Set Tax Field",SearchText,SearchField
		EndScript
	EndObject
	AreaButton "Dist + Button"
		Definition
			Origin 467,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Set Field",7
		EndScript
		OnClick
			Do "Format $","Dist + Button",Max(99999),Dist,"Dist","+",">",0
		EndScript
	EndObject
	AreaButton "Dist Button"
		Definition
			Origin 481,55
			Image "AMWAYDeck:AMWAY.br/Dist.b0"
			AltImage "AMWAYDeck:AMWAY.br/Dist.b1"
		EndScript
		OnRelease
			SetText ".Dist",""
			Do "Set Field",7
		EndScript
	EndObject
	AreaButton "Dist - Button"
		Definition
			Origin 520,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			Do "Set Field",7
		EndScript
		OnClick
			Do "Format $","Dist - Button",Min(0),Dist,"Dist","-","<",9999
		EndScript
	EndObject
	AreaButton "Cust + Button"
		Definition
			Origin 537,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Set Field",8
		EndScript
		OnClick
			Do "Format $","Cust + Button",Max(99999),Cust,"Cust","+",">",0
		EndScript
	EndObject
	AreaButton "Cust Button"
		Definition
			Origin 551,55
			Image "AMWAYDeck:AMWAY.br/Cost.b0"
			AltImage "AMWAYDeck:AMWAY.br/Cost.b1"
		EndScript
		OnRelease
			SetText ".Cust",""
			Do "Set Field",8
		EndScript
	EndObject
	AreaButton "Cust - Button"
		Definition
			Origin 590,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			Do "Set Field",8
		EndScript
		OnClick
			Do "Format $","Cust - Button",Min(0),Cust,"Cust","-","<",99999
		EndScript
	EndObject
	TextField ".VS"
		Definition
			InitialText ""
			Origin 9,73
			Size 88,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 11
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=1
		EndScript
		OnRelease
			Let VS=TextFrom(".VS")
			Do "Set Field",3
		EndScript
	EndObject
	IntegerField ".Qty"
		Definition
			Limits 1,99
			InitialInteger 1
			Origin 103,73
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 2
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=2
		EndScript
		OnRelease
			Let Qty=IntegerFrom(".Qty")
			Do "Set Field",3
		EndScript
	EndObject
	TextField ".Des"
		Definition
			InitialText ""
			Origin 133,73
			Size 160,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 20
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=3
		EndScript
		OnRelease
			Let Des=TextFrom(".Des")
			Do "Set Field",4
		EndScript
	EndObject
	TextField ".PV"
		Definition
			InitialText ""
			Origin 299,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=4
		EndScript
		OnRelease
			Do "Format Fields","PV",PV
			Do "Set Field",5
		EndScript
	EndObject
	TextField ".BV"
		Definition
			InitialText ""
			Origin 369,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=5
		EndScript
		OnRelease
			Do "Format Fields","BV",BV
			Do "Set Field",6
		EndScript
	EndObject
	TextField ".Tax"
		Definition
			InitialText ""
			Origin 439,73
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 4
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=6
		EndScript
		OnRelease
			Do "Set Field",7
		EndScript
	EndObject
	TextField ".Dist"
		Definition
			InitialText ""
			Origin 469,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=7
		EndScript
		OnRelease
			Do "Format Fields","Dist",Dist
			Do "Set Field",8
		EndScript
	EndObject
	TextField ".Cust"
		Definition
			InitialText ""
			Origin 539,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=8
		EndScript
		OnRelease
			Do "Format Fields","Cust",Cust
			Let Entry=GetDBObjects
			If Entry<>StockDataBase[StockIndex]
				DoObjectScript "Enter Button",ONRELEASE 
			EndIf
			Do "Set Field",1
		EndScript
	EndObject
	List "DataDoc"
		Definition
			ListDocument "Stock List" ; where the text comes from
			Origin 9,93
			Size 622,168
			Border INVERT BEVEL  ; BorderStyle, MainPen, ExtraPen
			Font "topaz",8 ; FontName, PointSize
		EndScript
		OnRelease
			WorkWithDocument "Stock List"
			Do "Get Entry",TheLineNumber
			Do "Set Field",CurrField
		EndScript
	EndObject
	TextMenu "New"
		Definition
			AttachTo MENU ,"Project..."
			Text "New..."
			ShortCutKey "N"
		EndScript
		Occurred
			DoObjectScript "New Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Load"
		Definition
			AttachTo MENU ,"Project..."
			Text "Load..."
			ShortCutKey "L"
		EndScript
		Occurred
			DoObjectScript "Load Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Save"
		Definition
			AttachTo MENU ,"Project..."
			Text "Save..."
			ShortCutKey "S"
		EndScript
		Occurred
			DoObjectScript "Save Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Save As"
		Definition
			AttachTo MENU ,"Project..."
			Text "Save As..."
			ShortCutKey "A"
		EndScript
		Occurred
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(TheCurrentDirectory||"AMWAYData/StockData/"||"Stock.Data","Select File To Load...")
			If FileOf(FileName)<>Nothing
				SaveVariable StockDataBase,FileName
				SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			Else
				Let StockDataBase[StockIndex]=GetDBObjects
			EndIf
		EndScript
	EndObject
	TextMenu "Previous"
		Definition
			AttachTo MENU ,"Project..."
			Text "Previous..."
			ShortCutKey "<"
		EndScript
		Occurred
			DoObjectScript "Previous Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Next"
		Definition
			AttachTo MENU ,"Project..."
			Text "Next..."
			ShortCutKey ">"
		EndScript
		Occurred
			DoObjectScript "Next Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Delete"
		Definition
			AttachTo MENU ,"Project..."
			Text "Delete..."
			ShortCutKey "D"
		EndScript
		Occurred
			DoObjectScript "Delete Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Find"
		Definition
			AttachTo MENU ,"Project..."
			Text "Find..."
			ShortCutKey "F"
		EndScript
		Occurred
			DoObjectScript "VS Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Distributor"
		Definition
			AttachTo MENU ,"Project..."
			Text "Distributor..."
			ShortCutKey "T"
		EndScript
		Occurred
			Let StockDataBase[StockIndex]=GetDBObjects
			SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			GotoCard "Distributor Card"
		EndScript
	EndObject
	TextMenu "Ordering"
		Definition
			AttachTo MENU ,"Project..."
			Text "Ordering..."
			ShortCutKey "O"
		EndScript
		Occurred
			Let StockDataBase[StockIndex]=GetDBObjects
			SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			GotoCard "Ordering Card"
		EndScript
	EndObject
	TextMenu "Customer"
		Definition
			AttachTo MENU ,"Project..."
			Text "Customer..."
			ShortCutKey "C"
		EndScript
		Occurred
			Let StockDataBase[StockIndex]=GetDBObjects
			SaveVariable StockDataBase,"Ram:AMWAYData/StockData/Stock.Data"
			GotoCard "Customer Card"
		EndScript
	EndObject
	TextMenu "Print"
		Definition
			AttachTo MENU ,"Project..."
			Text "Print..."
			ShortCutKey "P"
		EndScript
		Occurred
			SaveDocument "Stock List","Ram:AMWAYData/PrintData/Stock.list"
			Dos "C:Copy Ram:AMWAYData/PrintData/Stock.list PRT:"
		EndScript
	EndObject
	TextMenu "Quit"
		Definition
			AttachTo MENU ,"Project..."
			Text "Quit..."
			ShortCutKey "Q"
		EndScript
		Occurred
			Do "Quit"
		EndScript
	EndObject
* End of Card "DataBase Card"
*************

*************
* Card "Distributor Card"
	BeforeAttachment
		Dos "C:Assign AMWAYDeck: "||TheCurrentDirectory
		If Not Exists("Ram:AMWAYData/AMWAYPrefs")
			If Not Exists("AMWAYDeck:AMWAYData/AMWAYPrefs")
				Do "Load SubDeck"
				OpenWindow "AMWAYSubDeck","Prefs Card"
			ElseIf Exists("AMWAYDeck:AMWAYData/AMWAYPrefs")
				Do "Make Ram Dir"
				Dos "C:Copy AMWAYDeck:AMWAYData/AMWAYPrefs Ram:AMWAYData"
				Let AMWAYPrefs=LoadVariable("Ram:AMWAYData/AMWAYPrefs")
				Do "Load SubDeck"
			EndIf
		ElseIf Exists("Ram:AMWAYData/AMWAYPrefs")
			Do "Load SubDeck"
			Let AMWAYPrefs=LoadVariable("Ram:AMWAYData/AMWAYPrefs")
		EndIf
		If Not Exists("Ram:AMWAYData/AMWAYTax")
			If Exists("AMWAYDeck:AMWAYData/AMWAYTax")
				Dos "C:Copy AMWAYDeck:AMWAYData/AMWAYTax Ram:AMWAYData"
			EndIf
		EndIf
	EndScript
	AfterAttachment
		Do "Set Def"
		Let A=DefPenA
		Let B=DefPenB
		Let C=DefPenC
		Do "Get Fields","Name","Number","Day","Month","Year","Order","Sponsor"
		Let FieldNames[8]=".SponsorNo"
		If DefBGPic<>""
			ShowPicture DefTBGPic
		EndIf
		Do "Move Date"
		If Exists("Ram:AMWAYData/DistData/Dist.Data")
			Let DistDataBase=LoadVariable("Ram:AMWAYData/DistData/Dist.Data")
			SetDBObjects DistDataBase
		ElseIf Exists(DefDistDir||"/Dist.Data")
			Let DistDataBase=LoadVariable(DefDistDir||"/Dist.Data")
			SetDBObjects DistDataBase
			SaveVariable DistDataBase,"Ram:AMWAYData/DistData/Dist.Data"
		ElseIf Not Exists(DefDistDir||"Dist.Data")
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefDistDir||"/.Data","Select File To Load...")
			If FileOf(FileName)<>""
				Let DistDataBase=LoadVariable(FileName)
				IfError
					SetDBObjects Nothing
				Else
					SetDBObjects DistDataBase
					Let Name=TextFrom(".Name")
				EndIf
				If Name<>""
					SaveVariable DistDataBase,"Ram:AMWAYData/DistData/Dist.Data"
					SaveVariable DistDataBase,"Ram:AMWAYData/DistData/"||Name||".Data"
				EndIf
			Else
				Do "Get Date"
				Do "Set Date"
			EndIf
		EndIf
		Do "Display Number"
		Do "Get Dist Date"
		Do "Set Date"
	EndScript
	Routine "Make Ram Dir"
		If Not Exists("Ram:AMWAYData")
			Dos "C:MakeDir Ram:AMWAYData"
		EndIf
		If Not Exists("Ram:AMWAYData/DistData")
			Dos "C:MakeDir Ram:AMWAYData/DistData"
		EndIf
		If Not Exists("Ram:AMWAYData/StockData")
			Dos "C:MakeDir Ram:AMWAYData/StockData"
		EndIf
		If Not Exists("Ram:AMWAYData/OrderData")
			Dos "C:MakeDir Ram:AMWAYData/OrderData"
		EndIf
		If Not Exists("Ram:AMWAYData/CustData")
			Dos "C:MakeDir Ram:AMWAYData/CustData"
		EndIf
		If Not Exists("Ram:AMWAYData/PrintData")
			Dos "C:MakeDir Ram:AMWAYData/PrintData"
		EndIf
	EndScript
	Routine "Set Date"
		SetInteger ".Day",Day
		SetInteger ".Month",Month
		SetInteger ".Year",Year
	EndScript
	Routine "Display Name"
		Let Name=TextFrom(".Name")
		SetPen A,5
		If Name=""
			Do "Set Field",1
			PrintText "                         ",11,23
			PrintText "Distributor Screen...    ",11,23
		ElseIf Name<>""
			PrintText "                         ",11,23
			SetPen C,5
			PrintText LeftJustify(Name,25),11,23
		EndIf
	EndScript
	Routine "Move Date"
		SetPrintFont "topaz",8
		SetPrintStyle PLAIN ,2,1
		SetPen 1,5
		SetDrawMode JAM1 
		If DefDate="MDY"
			MoveObject ".Month",374,65
			MoveObject "Month + Button",372,42
			MoveObject "Month - Button",372,86
			MoveObject ".Day",407,65
			MoveObject "Day + Button",405,42
			MoveObject "Day - Button",405,86
			PrintText "M",390,45
			PrintText "M",390,90
			PrintText "D",424,45
			PrintText "D",424,90
		Else
			PrintText "D",390,45
			PrintText "D",390,90
			PrintText "M",424,45
			PrintText "M",424,90
		EndIf
		PrintText "Y",456,46
		PrintText "Y",456,90
		PrintText "O",584,45
		PrintText "O",584,90
	EndScript
	Routine "Get Dist Date"
		Let Day=IntegerFrom(".Day")
		Let Month=IntegerFrom(".Month")
		Let Year=IntegerFrom(".Year")
		Let Order=IntegerFrom(".Order")
	EndScript
	Routine "Date Format"
		If DefDate="MDY"
			Do "Display Date",317,400,432,415,382,448
		Else
			Do "Display Date",317,400,432,382,415,448
		EndIf
		Do "Display Order",493,577
	EndScript
	Routine "Goto Card"
		Let Name=TextFrom(".Name")
		Let Number=IntegerFrom(".Number")
		If Name=""
			Do "Display Number"
		ElseIf Number=0
			Do "Display Number"
		Else
			Do "Make Dist Doc"
			Let DistDataBase=GetDBObjects
			SaveVariable DistDataBase,"Ram:AMWAYData/DistData/Dist.Data"
			SaveVariable DistDataBase,"Ram:AMWAYData/DistData/"||Name||".Data"
			GotoCard Arg1||" Card"
		EndIf
	EndScript
	Routine "Set Order"
		Let Day=IntegerFrom(".Day")
		If Day<=7
			Let Order=1
		ElseIf Day<=14
			Let Order=2
		ElseIf Day<=21
			Let Order=3
		ElseIf Day<=28
			Let Order=4
		ElseIf Day<=32
			Let Order=5
		EndIf
		SetInteger ".Order",Order
		Do "Display Order",493,577
	EndScript
	Routine "Make Dist Doc"
		WorkWithDocument "Ram:AMWAYData/DistData/Dist.Doc"
		Clear DOCUMENT 
		Type " ",NEWLINE 
		Type "                         Intra Group Order Form.",NEWLINE 
		Type "                         ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
		Type LeftJustify("Your Name",25)
		Type LeftJustify("Your Number",12)
		Type "     "
		Type LeftJustify("Today's Date",12)
		Type "     "
		Type LeftJustify("Your Order No.",15)
		NewLine
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ"
		NewLine
		Type LeftJustify(Name,26)
		Type " "
		Type LeftJustify(Number,7)
		Type "         "
		If DefDate="MDY"
			Type RightJustify(Month,2)
			Type "/"
			Type RightJustify(Day,2)
		Else
			Type RightJustify(Day,2)
			Type "/"
			Type RightJustify(Month,2)
		EndIf
		Type "/"
		Type RightJustify(Year,4)
		Type "            "
		Type CenterString(Order,1)
		NewLine
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ"
		NewLine
		Type LeftJustify("Sponsor",25)
		Type LeftJustify("Sponsor Number",15)
		NewLine
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ"
		NewLine
		Type LeftJustify(Sponsor,26)
		Type " "
		Type LeftJustify(SponsorNo,7)
		NewLine
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ"
		NewLine
		SaveDocument "Ram:AMWAYData/DistData/Dist.Doc"
		SaveDocument "Ram:AMWAYData/DistData/Dist.Doc","Ram:AMWAYData/PrintData/Dist.Doc"
	EndScript
	Routine "Format Date"
		While ObjectState(Arg1||Arg2||"Button")
			Let Arg3=IntegerFrom("."||Arg1)
			Let Arg3=Arg3||Arg4||1
			If Arg3||Arg5||Arg6
				Let Arg3=Arg7
			EndIf
			Delay 0,0,10
			SetInteger "."||Arg1,Arg3
			Do "Get Dist Date"
			Do "Date Format"
		EndLoop
	EndScript
	Routine "Display Number"
		Let Name=TextFrom(".Name")
		Let Sponsor=TextFrom(".Sponsor")
		Let Number=IntegerFrom(".Number")
		SetPen A,5
		PrintText "#",219,23
		SetPen C,5
		PrintText LeftJustify(Number,7),228,23
		Do "Get Dist Date"
		If Number=0
			If Name<>""
				Do "Set Field",2
				Do "Display Name"
			Else
				Do "Display Name"
			EndIf
		Else
			Do "Display Name"
			If Sponsor=""
				Do "Set Field",7
			ElseIf Sponsor<>""
				Do "Set Field",8
			EndIf
		EndIf
		Do "Date Format"
	EndScript
	Routine "Load SubDeck"
		If Not Exists("AMWAYDeck:SubDecks/AMWAYSubDeck")
			Let Response=AskForResponse("The Prefs Function for this program"||char(10)||"         has not been found."||char(10)||"          Continue anyway?","!!!WARNING!!!","Okay|Quit")
			If (Response=1)
				Let Response=AskforResponse("Some features of this program may"||char(10)||"        not work properly."||char(10)||"         Continue anyway?","!!!2nd WARNING!!!","Okay|Quit")
				If (Response=2)
					Do "Quit"
				EndIf
			ElseIf (Response=2)
				Do "Quit"
			EndIf
		EndIf
		LoadSubDeck "AMWAYDeck:SubDecks/AMWAYSubDeck","AMWAYSubDeck"
	EndScript
	Window "UserWindow"
		Definition
			Origin 0,12
			Title "Distributor Screen..."
			WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR 
			Size 607,135
			DefaultColors 1,0,5
			WindowFlags ACTIVATE TOFRONT WORKBENCH 
			VisualEffects NONE ,WAIT 
		EndScript
		OnCloseButton
			Do "Quit"
		EndScript
	EndObject
	AreaButton "Info BarA"
		Definition
			Origin 9,20
			Image "AMWAYDeck:AMWAY.br/BarA.br"
			Highlight NONE 
		EndScript
	EndObject
	AreaButton "Info BarB"
		Definition
			Origin 259,20
			Image "AMWAYDeck:AMWAY.br/BarB.br"
			Highlight NONE 
		EndScript
	EndObject
	AreaButton "Name Button"
		Definition
			Origin 9,42
			Image "AMWAYDeck:AMWAY.br/Name.b0"
			AltImage "AMWAYDeck:AMWAY.br/Name.b1"
		EndScript
		OnRelease
			SetText ".Name",""
			Do "Display Number"
		EndScript
	EndObject
	AreaButton "Number Button"
		Definition
			Origin 226,42
			Image "AMWAYDeck:AMWAY.br/Num.b0"
			AltImage "AMWAYDeck:AMWAY.br/Num.b1"
		EndScript
		OnRelease
			SetInteger ".Number",0
			Do "Display Number"
		EndScript
	EndObject
	AreaButton "Date Button"
		Definition
			Origin 299,42
			Image "AMWAYDeck:AMWAY.br/Date.b0"
			AltImage "AMWAYDeck:AMWAY.br/Date.b1"
		EndScript
		OnRelease
			Do "Get Date"
			Do "Set Date"
			Do "Set Order"
			Do "Date Format"
			SetObjectState ".Day",On
		EndScript
	EndObject
	AreaButton "Day + Button"
		Definition
			Origin 372,42
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnClick
			Do "Format Date","Day"," + ",Day,"+",">",32,1
		EndScript
		OnRelease
			Do "Get Dist Date"
			Do "Set Order"
			Do "Set Field",3
		EndScript
	EndObject
	AreaButton "Day - Button"
		Definition
			Origin 372,86
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnClick
			Do "Format Date","Day"," - ",Day,"-","=",0,32
		EndScript
		OnRelease
			Do "Get Dist Date"
			Do "Set Order"
			Do "Set Field",3
		EndScript
	EndObject
	AreaButton "Month + Button"
		Definition
			Origin 405,42
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnClick
			Do "Format Date","Month"," + ",Month,"+",">",12,1
		EndScript
		OnRelease
			Do "Get Dist Date"
			Do "Set Order"
			Do "Set Field",4
		EndScript
	EndObject
	AreaButton "Month - Button"
		Definition
			Origin 405,86
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnClick
			Do "Format Date","Month"," - ",Month,"-","=",0,12
		EndScript
		OnRelease
			Do "Get Dist Date"
			Do "Set Order"
			Do "Set Field",4
		EndScript
	EndObject
	AreaButton "Year + Button"
		Definition
			Origin 438,42
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnClick
			Do "Format Date","Year"," + ",Year,"+",">",9999
		EndScript
		OnRelease
			Do "Get Dist Date"
			Do "Set Order"
			Do "Set Field",5
		EndScript
	EndObject
	AreaButton "Year - Button"
		Definition
			Origin 438,86
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnClick
			Do "Format Date","Year"," - ",Year,"-","=",0,9999
		EndScript
		OnRelease
			Do "Get Dist Date"
			Do "Set Order"
			Do "Set Field",5
		EndScript
	EndObject
	AreaButton "Order Button"
		Definition
			Origin 487,42
			Image "AMWAYDeck:AMWAY.br/OrdN.b0"
			AltImage "AMWAYDeck:AMWAY.br/OrdN.b1"
		EndScript
		OnRelease
			Let Order=1
			SetInteger ".Order",1
			Do "Date Format"
			Do "Set Field",6
		EndScript
	EndObject
	AreaButton "Order + Button"
		Definition
			Origin 567,42
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnClick
			Do "Format Date","Order"," + ",Order,"+",">",5,1
		EndScript
		OnRelease
			Do "Get Dist Date"
			Do "Set Field",6
		EndScript
	EndObject
	AreaButton "Order - Button"
		Definition
			Origin 567,86
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnClick
			Do "Format Date","Order"," - ",Order,"-","=",0,5
		EndScript
		OnRelease
			Do "Get Dist Date"
			Do "Set Field",6
		EndScript
	EndObject
	AreaButton "New Button"
		Definition
			Origin 487,86
			Image "AMWAYDeck:AMWAY.br/New.b0"
			AltImage "AMWAYDeck:AMWAY.br/New.b1"
		EndScript
		OnRelease
			Dispose DistDataBase
			SetDBObjects Nothing
			Do "Display Number"
		EndScript
	EndObject
	AreaButton "Quit Button"
		Definition
			Origin 522,86
			Image "AMWAYDeck:AMWAY.br/Quit.b0"
			AltImage "AMWAYDeck:AMWAY.br/Quit.b1"
		EndScript
		OnRelease
			Do "Quit"
		EndScript
	EndObject
	AreaButton "Sponsor Button"
		Definition
			Origin 9,86
			Image "AMWAYDeck:AMWAY.br/Spon.b0"
			AltImage "AMWAYDeck:AMWAY.br/Spon.b1"
		EndScript
		OnRelease
			SetText ".Sponsor",""
			Do "Set Field",7
		EndScript
	EndObject
	AreaButton "SponsorNo Button"
		Definition
			Origin 226,86
			Image "AMWAYDeck:AMWAY.br/Num.b0"
			AltImage "AMWAYDeck:AMWAY.br/Num.b1"
		EndScript
		OnRelease
			SetInteger ".SponsorNo",0
			Let Sponsor=TextFrom(".Sponsor")
			If Sponsor=""
				Do "Set Field",7
			Else
				Do "Set Field",8
			EndIf
		EndScript
	EndObject
	AreaButton "Load Button"
		Definition
			Origin 299,86
			Image "AMWAYDeck:AMWAY.br/Load.b0"
			AltImage "AMWAYDeck:AMWAY.br/Load.b1"
		EndScript
		OnRelease
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefDistDir||"/.Data","Select File To Load...")
			If FileOf(FileName)<>Nothing
				Let DistDataBase=LoadVariable(FileName)
				SetDBObjects DistDataBase
				SaveVariable DistDataBase,"Ram:AMWAYData/DistData/Dist.Data"
			Else
				Let DistDataBase=GetDBObjects
				Do "Set Date"
				Do "Set Order"
			EndIf
			Do "Display Number"
			Do "Date Format"
			Do "Set Order"
		EndScript
	EndObject
	AreaButton "Save Button"
		Definition
			Origin 299,108
			Image "AMWAYDeck:AMWAY.br/Save.b0"
			AltImage "AMWAYDeck:AMWAY.br/Save.b1"
		EndScript
		OnRelease
			Let Name=TextFrom(".Name")
			Let Number=IntegerFrom(".Number")
			If Name=""
				Do "Display Number"
			ElseIf Number=0
				Do "Display Number"
			Else
				Let DistDataBase=GetDBObjects
				SaveVariable DistDataBase,"Ram:AMWAYData/DistData/Dist.Data"
				SaveVariable DistDataBase,"Ram:AMWAYData/DistData/"||Name||".Data"
				SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
				SetFileRequestPattern "#?.Data"
				Let FileName=AskForFileName(DefDistDir||"/"||Name||".Data","Save File...")
				If FileOf(FileName)<>Nothing
					SaveVariable DistDataBase,FileName
					SaveVariable DistDataBase,DefDistDir||"/"||"Dist.Data"
					SaveVariable DistDataBase,DefDistDir||"/"||Name||".Data"
				EndIf
			EndIf
			Do "Display Number"
			Do "Date Format"
		EndScript
	EndObject
	AreaButton "Prefs Button"
		Definition
			Origin 372,108
			Image "AMWAYDeck:AMWAY.br/Prefs.b0"
			AltImage "AMWAYDeck:AMWAY.br/Prefs.b1"
		EndScript
		OnRelease
			Dos "C:DeckRunner AMWAYDeck:SubDecks/AMWAYSubDeck"
		EndScript
	EndObject
	AreaButton "DataBase Button"
		Definition
			Origin 438,108
			Image "AMWAYDeck:AMWAY.br/OD.b0"
			AltImage "AMWAYDeck:AMWAY.br/OD.b1"
		EndScript
		OnRelease
			Do "Goto Card","DataBase"
		EndScript
	EndObject
	TextField ".Name"
		Definition
			InitialText ""
			Origin 11,65
			Size 208,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 25
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=1
			Let OldName=TextFrom(".Name")
		EndScript
		OnRelease
			Let Name=TextFrom(".Name")
			If Name<>OldName
				SetInteger ".Number",0
				Do "Display Number"
			Else
				Do "Display Number"
				Do "Set Order"
			EndIf
		EndScript
	EndObject
	IntegerField ".Number"
		Definition
			Limits 0,9999999
			InitialInteger 0
			Origin 228,65
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=2
		EndScript
		OnRelease
			Do "Display Number"
		EndScript
	EndObject
	IntegerField ".Day"
		Definition
			Limits 1,32
			InitialInteger 1
			Origin 374,65
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 2
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=3
		EndScript
		OnRelease
			If DefDate="MDY"
				Do "Display Date",317,400,432,415,382,448
			Else
				Do "Display Date",317,400,432,382,415,448
			EndIf
			Do "Set Order"
			Do "Set Field",4
		EndScript
	EndObject
	IntegerField ".Month"
		Definition
			Limits 1,12
			InitialInteger 1
			Origin 407,65
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 2
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=4
		EndScript
		OnRelease
			If DefDate="MDY"
				Do "Display Date",317,400,432,415,382,448
			Else
				Do "Display Date",317,400,432,382,415,448
			EndIf
			Do "Set Order"
			Do "Set Field",5
		EndScript
	EndObject
	IntegerField ".Year"
		Definition
			Limits 0,9999
			InitialInteger 0
			Origin 440,65
			Size 40,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 4
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=5
		EndScript
		OnRelease
			If DefDate="MDY"
				Do "Display Date",317,400,432,415,382,448
			Else
				Do "Display Date",317,400,432,382,415,448
			EndIf
			Do "Set Order"
			Do "Set Field",6
		EndScript
	EndObject
	IntegerField ".Order"
		Definition
			Limits 1,5
			InitialInteger 1
			Origin 569,65
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification CENTER 
			MaxFieldLength 1
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=6
		EndScript
		OnRelease
			If DefDate="MDY"
				Do "Display Date",317,400,432,415,382,448
			Else
				Do "Display Date",317,400,432,382,415,448
			EndIf
			Do "Set Order"
			Do "Set Field",7
		EndScript
	EndObject
	TextField ".Sponsor"
		Definition
			InitialText ""
			Origin 11,109
			Size 208,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 25
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=7
			Let OldSponsor=TextFrom(".Sponsor")
		EndScript
		OnRelease
			Let Sponsor=TextFrom(".Sponsor")
			If Sponsor=""
				Do "Display Number"
				Do "Set Field",7
			ElseIf Sponsor<>OldSponsor
				SetInteger ".SponsorNo",0
				Do "Display Number"
				Do "Set Field",8
			Else
				Do "Set Field",8
			EndIf
		EndScript
	EndObject
	IntegerField ".SponsorNo"
		Definition
			Limits 0,9999999
			InitialInteger 0
			Origin 228,109
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=8
		EndScript
		OnRelease
			Let Name=TextFrom(".Name")
			Let Number=IntegerFrom(".Number")
			Let Sponsor=TextFrom(".Sponsor")
			Let SponsorNo=IntegerFrom(".SponsorNo")
			If Sponsor=""
				Do "Set Field",7
			ElseIf SponsorNo=0
				Do "Set Field",8
			Else
				If Name=""
					Do "Display Number"
				ElseIf Number=0
					Do "Display Number"
				Else
					Do "Make Dist Doc"
					Let DistDataBase=GetDBObjects
					SaveVariable DistDataBase,"Ram:AMWAYData/DistData/Dist.Data"
					SaveVariable DistDataBase,"Ram:AMWAYData/DistData/"||Name||".Data"
					GotoCard "DataBase Card"
				EndIf
			EndIf
		EndScript
	EndObject
	TextMenu "New"
		Definition
			AttachTo MENU ,"Project..."
			Text "New..."
			ShortCutKey "N"
		EndScript
		Occurred
			DoObjectScript "New Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Load"
		Definition
			AttachTo MENU ,"Project..."
			Text "Load..."
			ShortCutKey "L"
		EndScript
		Occurred
			DoObjectScript "Load Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Save"
		Definition
			AttachTo MENU ,"Project..."
			Text "Save..."
			ShortCutKey "S"
		EndScript
		Occurred
			Let DistDataBase=GetDBObjects
			SaveVariable DistDataBase,"Ram:AMWAYData/DistData/Dist.Data"
			SaveVariable DistDataBase,"Ram:AMWAYData/DistData/"||Name||".Data"
			SaveVariable DistDataBase,DefDistDraw||"Dist.Data"
			SaveVariable DistDataBase,DefDistDraw||Name||".Data"
			Do "Display Number"
		EndScript
	EndObject
	TextMenu "Save As"
		Definition
			AttachTo MENU ,"Project..."
			Text "Save As..."
			ShortCutKey "A"
		EndScript
		Occurred
			DoObjectScript "Save Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "DataBase"
		Definition
			AttachTo MENU ,"Project..."
			Text "DataBase..."
			ShortCutKey "B"
		EndScript
		Occurred
			DoObjectScript "DataBase Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Ordering"
		Definition
			AttachTo MENU ,"Project..."
			Text "Ordering..."
			ShortCutKey "O"
		EndScript
		Occurred
			Do "Goto Card","Ordering"
		EndScript
	EndObject
	TextMenu "Customer"
		Definition
			AttachTo MENU ,"Project..."
			Text "Customer..."
			ShortCutKey "C"
		EndScript
		Occurred
			Do "Goto Card","Customer"
		EndScript
	EndObject
	TextMenu "Prefs"
		Definition
			AttachTo MENU ,"Project..."
			Text "Prefs..."
			ShortCutKey "P"
		EndScript
		Occurred
			DoObjectScript "Prefs Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "About"
		Definition
			AttachTo MENU ,"Project..."
			Text "About..."
		EndScript
	EndObject
	TextMenu "Version"
		Definition
			AttachTo OBJECT ,"About"
			Text "AMWAYDeck V5.0"
		EndScript
	EndObject
	TextMenu "TG"
		Definition
			AttachTo OBJECT ,"About"
			Text "Thomas R. Grant"
		EndScript
	EndObject
	TextMenu "Email"
		Definition
			AttachTo OBJECT ,"About"
			Text "tgrant@merlin.net.au"
		EndScript
	EndObject
	TextMenu "Add1"
		Definition
			AttachTo OBJECT ,"About"
			Text "265 Robin Road"
		EndScript
	EndObject
	TextMenu "Add2"
		Definition
			AttachTo OBJECT ,"About"
			Text "Semaphore 5019"
		EndScript
	EndObject
	TextMenu "SA"
		Definition
			AttachTo OBJECT ,"About"
			Text "South Australia"
		EndScript
	EndObject
	TextMenu "Phone1"
		Definition
			AttachTo OBJECT ,"About"
			Text "(08)84 493690"
		EndScript
	EndObject
	TextMenu "Phone2"
		Definition
			AttachTo OBJECT ,"About"
			Text "(08)8 2423506"
		EndScript
	EndObject
	TextMenu "Quit"
		Definition
			AttachTo MENU ,"Project..."
			Text "Quit..."
			ShortCutKey "Q"
		EndScript
		Occurred
			Do "Quit"
		EndScript
	EndObject
* End of Card "Distributor Card"
*************

*************
* Card "Ordering Card"
	NoAttach
	Routine "Store Entry"
		WorkWithDocument "Order List"
		Let Work=GetDBObjects
		If Work<>OrderDataBase[OrderIndex]
			Do "Delete Entry",OrderIndex
			Let OrderIndex=TheLineNumber
			InsertArrayEntry OrderDataBase,OrderIndex
			Let OrderDataBase[OrderIndex]=Work
		EndIf
		Do "Load DataFile"
	EndScript
	Routine "Get Entry"
		SetPrintFont "topaz",8
		SetDrawMode JAM2 
		SetPen B,5
		SetPrintStyle PLAIN ,B,3
		Let OrderIndex=Arg1
		SetDBObjects OrderDataBase[OrderIndex]
		PrintText RightJustify(OrderIndex,4),570,23
		PrintText RightJustify(NumberOfArrayEntries(OrderDataBase),4),380,23
		SetPen A,5
		PrintText "Ordering Info...",11,23
		PrintText "There Are :",293,23
		PrintText "Items",420,23
		PrintText "Index No.",500,23
		WorkWithDocument "Order List"
		PositionOnLine Arg1
		If DefDate="MDY"
			Do "Display Date",740,200,234,209,176,243
		Else
			Do "Display Date",740,200,234,176,209,243
		EndIf
	EndScript
	Routine "Set Tax Field"
		If Arg1
			Let TaxAmount=Arg2
			Let TaxField=Arg3
			Do "Get VS"
			SetText ".Tax",TaxField
			Do "Tax"
			Do "Tax Amounts"
			Let OrderDataBase[OrderIndex]=GetDBObjects
			Let SearchText=TextFrom(".VS")
			Let SearchField="VS"
			Do "Search Next"
			DoObjectScript "Enter Button",ONRELEASE 
			Do "Search Next"
		EndIf
		Do "Set Field",1
	EndScript
	Routine "Do Search"
		If Arg1
			SetText ".VS",Arg5.VS
			SetText ".Des",Arg5.Des
			SetText ".PV",Arg5.PV
			SetText ".BV",Arg5.BV
			SetText ".Tax",Arg5.Tax
			Let Dist=Arg5.Dist
			Let Cust=Arg5.Cust
			Do "Tax Amounts"
			Let StockIndex=Arg4
			Let SearchText=TextFrom(".VS")
			Let SearchField="VS"
			Do "Search Next"
			DoObjectScript "Enter Button",ONRELEASE 
			Do "Search Next"
		EndIf
	EndScript
	Routine "Totals"
		Let TotalPV=TotalPV+OrderDataBase[OrderIndex].PV
		Let TotalBV=TotalBV+OrderDataBase[OrderIndex].BV
		Let TotalQty=TotalQty+OrderDataBase[OrderIndex].Qty
		Let TotalDist=TotalDist+OrderDataBase[OrderIndex].Dist
		Let TotalCust=TotalCust+OrderDataBase[OrderIndex].Cust
		Let TotalProfit=TotalCust-TotalDist
		Do "Calc Tax"
	EndScript
	Routine "Tax Amounts"
		Let TaxDist=0
		Let TaxCust=0
		Let ATX=TextFrom(".Tax")
		Let Qty=IntegerFrom(".Qty")
		Do "Format Fields","Dist",Dist
		Do "Format Fields","Cust",Cust
		If ATX="Tax"
			Let TaxDist=(Qty*Dist)+(Dist/100*Tax)
			Let TaxCust=(Qty*Cust)+(Cust/100*Tax)
		ElseIf ATX="GST"
			Let TaxDist=(Qty*Dist)+(Dist/100*GST)
			Let TaxCust=(Qty*Cust)+(Cust/100*GST)
		ElseIf ATX="PST"
			Let TaxDist=(Qty*Dist)+(Dist/100*PST)
			Let TaxCust=(Qty*Cust)+(Cust/100*PST)
		ElseIf ATX="VAT1"
			Let TaxDist=(Qty*Dist)+(Dist/100*VAT1)
			Let TaxCust=(Qty*Cust)+(Cust/100*VAT1)
		ElseIf ATX="VAT2"
			Let TaxDist=(Qty*Dist)+(Dist/100*VAT1)
			Let TaxCust=(Qty*Cust)+(Cust/100*VAT1)
		ElseIf ATX<>""
			Let ATX=FormatValue(TextFrom(".Tax"),"####")
			Let TaxDist=(Qty*Dist)+(Dist/100*ATX)
			Let TaxCust=(Qty*Cust)+(Cust/100*ATX)
		ElseIf ATX=""
			Let TaxDist=Dist
			Let TaxCust=Cust
		EndIf
		SetText ".Dist",TaxDist
		SetText ".Cust",TaxCust
		Do "Format Fields","Dist",TaxDist
		Do "Format Fields","Cust",TaxCust
	EndScript
	Routine "Delete Entry"
		DeleteArrayEntry OrderDataBase,Arg1
		PositionOnLine Arg1
		If TheLineNumber=LinesInDocument
			Clear LINE 
			Delete CHARACTER ,-1
			Let OrderIndex=0
		Else
			Delete LINE 
		EndIf
		Do "Load DataFile"
		PositionOnLine Arg1
	EndScript
	Routine "Draw Card"
		SetDrawMode JAM2 
		SetPen 0
		AreaRectangle 9,93,601,168
		SetPen 5
		AreaRectangle 7,270,626,60
		DrawBorder 7,270,626,60,BEVEL ,4,2
		SetPen A,5
		PrintText "Qty",112,275
		PrintText "Profit =",147,275
		PrintText "Total(s)",230,275
		PrintText "P.V. =",316,275
		PrintText "B.V. =",385,275
		PrintText "Dist =",485,275
		PrintText "Cost =",555,275
		PrintText "Tax Payable :",10,300
		PrintText "Customer Tax:",10,315
	EndScript
	Routine "Print Totals"
		SetDrawMode JAM2 
		SetPrintFont "topaz",8
		SetPen B,5
		PrintText RightJustify(TotalQty,2),113,285
		PrintText RightJustify(FormatValue(TotalPV,"###0.00"),7),308,285
		PrintText RightJustify(FormatValue(TotalBV,"###0.00"),7),377,285
		PrintText RightJustify(FormatValue(TotalDist,DefNote||"###0.00"),7),478,285
		PrintText RightJustify(FormatValue(TotalCust,DefNote||"###0.00"),7),548,285
		PrintText RightJustify(FormatValue(TotalProfit,DefNote||"###0.00"),7),155,285
	EndScript
	Routine "Search Next"
		WorkWithDocument "Order List"
		Local NewOrderIndex
		SetSearchArrayFlags NOCASE SUBSTRING 
		Let NewOrderIndex=SearchArray(OrderDataBase,SearchText,"."||SearchField,OrderIndex+1)
		If Not SearchFound
			Let NewOrderIndex=SearchArray(OrderDataBase,SearchText,"."||SearchField)
			If Not SearchFound
				If SizeOfDocument<>0
					MoveCursorTo STARTOF DOCUMENT 
					SplitLine
					MoveCursor UP 
					Let OrderIndex=1
					InsertArrayEntry OrderDataBase,OrderIndex
					Let OrderDataBase[OrderIndex]=GetDBObjects
				EndIf
			EndIf
		EndIf
		If SearchFound
			Do "Get Entry",NewOrderIndex
		EndIf
	EndScript
	AfterAttachment
		Do "Set Def"
		Do "Tax"
		If DefBGPic<>""
			ShowPicture DefOBGPic
		EndIf
		Do "Draw Card"
		FastFeedBack On
		Dispose Work
		Let Sort="Yes"
		Do "Get Fields","VS","Qty","Des","PV","BV","Tax","Dist"
		Let FieldNames[8]=".Cust"
		If Exists("Ram:AMWAYData/OrderData/Order.Data")
			Let OrderDataBase=LoadVariable("Ram:AMWAYData/OrderData/Order.Data")
			Do "Load DataFile"
		ElseIf Exists(DefOrdDir||"/Order.Data")
			Let OrderDataBase=LoadVariable(DefOrdDir||"/Order.Data")
			Do "Load DataFile"
			SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
		ElseIf Not Exists(DefOrdDir||"/Order.Data")
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefOrdDir||"/.Data","Select File To Load...")
			If FileOf(FileName)<>""
				Let OrderDataBase=LoadVariable(FileName)
				Do "Load DataFile"
				SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			Else
				Let OrderIndex=1
				Let OrderDataBase[OrderIndex]=GetDBObjects
				Do "Load DataFile"
				SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			EndIf
		EndIf
		Do "Tax Amounts"
		Let StockIndex=Arg4
		Let SearchText=TextFrom(".VS")
		Let SearchField="VS"
		Do "Search Next"
		DoObjectScript "Enter Button",ONRELEASE 
		Do "Search Next"
		Do "Get Date"
		Do "Get Entry",1
		Do "Set Field",1
	EndScript
	MessageFromSubDeck
		If Arg1<>""
			Do Arg1,Alias("Arg2"),Alias("Arg3"),Alias("Arg4"),Alias("Arg5"),Alias("Arg6")
		EndIf
	EndScript
	Routine "Print Calc Totals"
		SetDrawMode JAM2 
		If ATX="Tax"
			SetPen A,5
			PrintText "Tax=",122,300
			PrintText "Tax=",122,315
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxDistT,DefNote||"###0.00"),7),154,300
			PrintText RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7),154,315
		ElseIf ATX="GST"
			SetPen A,5
			PrintText "GST=",122,300
			PrintText "GST=",122,315
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxDistG,DefNote||"###0.00"),7),154,300
			PrintText RightJustify(FormatValue(TotalTaxCustG,DefNote||"###0.00"),7),154,315
		ElseIf ATX="PST"
			SetPen A,5
			PrintText "PST=",218,300
			PrintText "PST=",218,315
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxDistP,DefNote||"###0.00"),7),250,300
			PrintText RightJustify(FormatValue(TotalTaxCustP,DefNote||"###0.00"),7),250,315
		ElseIf ATX="VAT1"
			SetPen A,5
			PrintText "VAT1=",122,300
			PrintText "VAT1=",122,315
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxDistV1,DefNote||"###0.00"),7),154,300
			PrintText RightJustify(FormatValue(TotalTaxCustV1,DefNote||"###0.00"),7),154,315
		ElseIf ATX="VAT2"
			SetPen A,5
			PrintText "VAT2=",218,300
			PrintText "VAT2=",218,315
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxDistV2,DefNote||"###0.00"),7),250,300
			PrintText RightJustify(FormatValue(TotalTaxCustV2,DefNote||"###0.00"),7),250,315
		ElseIf ATX<>""
			SetPen A,5
			PrintText "Tax=",122,300
			PrintText "Tax=",122,315
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxDistT,DefNote||"###0.00"),7),154,300
			PrintText RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7),154,315
		ElseIf ATX=""
			SetPen A,5
			PrintText "Tax=",122,300
			PrintText "Tax=",122,315
			SetPen C,5
			PrintText RightJustify(FormatValue(TotalTaxDistT,DefNote||"###0.00"),7),154,300
			PrintText RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7),154,315
		EndIf
	EndScript
	Routine "Set Totals"
		Let ATC=0
		Let TotalPV=0
		Let TotalBV=0
		Let TotalQty=0
		Let TotalDist=0
		Let TotalCust=0
		Let TotalProfit=0
		Let TotalTaxDist=0
		Let TotalTaxCust=0
		Let TotalTaxDistT=0
		Let TotalTaxCustT=0
		Let TotalTaxDistG=0
		Let TotalTaxCustG=0
		Let TotalTaxDistP=0
		Let TotalTaxCustP=0
		Let TotalTaxDistV1=0
		Let TotalTaxCustV1=0
		Let TotalTaxDistV2=0
		Let TotalTaxCustV2=0
	EndScript
	Routine "Calc Tax"
		Let Qty=IntegerFrom(".Qty")
		If ATX="Tax"
			Let TotalTaxDistT=TotalTaxDistT+(Qty*Dist/100*Val)
			Let TotalTaxCustT=TotalTaxCustT+(Qty*Cust/100*Val)
		ElseIf ATX="GST"
			If ATC=1
				Let ATC=2
			Else
				Let ATC=1
			EndIf
			Let TotalTaxDistG=TotalTaxDistG+(Qty*Dist/100*Val)
			Let TotalTaxCustG=TotalTaxCustG+(Qty*Cust/100*Val)
		ElseIf ATX="PST"
			If ATC=1
				Let ATC=2
			Else
				Let ATC=1
			EndIf
			Let TotalTaxDistP=TotalTaxDistP+(Qty*Dist/100*Val)
			Let TotalTaxCustP=TotalTaxCustP+(Qty*Cust/100*Val)
		ElseIf ATX="VAT1"
			If ATC=1
				Let ATC=2
			Else
				Let ATC=1
			EndIf
			Let TotalTaxDistV1=TotalTaxDistV1+(Qty*Dist/100*Val)
			Let TotalTaxCustV1=TotalTaxCustV1+(Qty*Cust/100*Val)
		ElseIf ATX="VAT2"
			If ATC=1
				Let ATC=2
			Else
				Let ATC=1
			EndIf
			Let TotalTaxDistV2=TotalTaxDistV2+(Qty*Dist/100*Val)
			Let TotalTaxCustV2=TotalTaxCustV2+(Qty*Cust/100*Val)
		ElseIf ATX<>""
			Let ATX=FormatValue(TextFrom(".Tax"),"####")
			Let TotalTaxDist=TotalTaxDist+(Qty*Dist/100*ATX)
			Let TotalTaxCust=TotalTaxCust+(Qty*Cust/100*ATX)
		ElseIf ATX=""
			Let TotalTaxDist=TotalTaxDist+(Qty*Dist/100*Val)
			Let TotalTaxCust=TotalTaxCust+(Qty*Cust/100*Val)
		EndIf
		Do "Print Calc Totals"
	EndScript
	Routine "Load DataFile"
		Do "Set Totals"
		WorkWithDocument "Order List"
		Clear DOCUMENT 
		If Sort="Yes"
			SortArray OrderDataBase,INTEGER ,".VS"
		EndIf
		Let OrderIndex=FirstArrayIndex(OrderDataBase)
		PrintText "                                 ",122,300
		PrintText "                                 ",122,315
		While SearchFound
			Type LeftJustify(OrderDataBase[OrderIndex].VS,11)
			Type " "
			Type RightJustify(OrderDataBase[OrderIndex].Qty,2)
			Type " "
			Type LeftJustify(OrderDataBase[OrderIndex].Des,20)
			Type "  "
			Type RightJustify(FormatValue(OrderDataBase[OrderIndex].PV,"###0.00"),7)
			Type "  "
			Type RightJustify(FormatValue(OrderDataBase[OrderIndex].BV,"###0.00"),7)
			Type " "
			If T="Yes"
				Let ATX=OrderDataBase[OrderIndex].Tax
				Do "Get VS",OrderDataBase[OrderIndex].VS
				Let Val=FormatValue(OrderDataBase[OrderIndex].Tax,"####")
				Type LeftJustify(FormatValue(OrderDataBase[OrderIndex].Tax,"###%"),4)
			Else
				Type LeftJustify(FormatValue(OrderDataBase[OrderIndex].Tax,"###%"),4)
			EndIf
			Type " "
			Type RightJustify(FormatValue(OrderDataBase[OrderIndex].Dist,DefNote||"###0.00"),7)
			Type " "
			Type RightJustify(FormatValue(OrderDataBase[OrderIndex].Cust,DefNote||"###0.00"),7)
			Do "Totals"
			NewLine
			Let OrderIndex=NextArrayIndex(OrderDataBase,OrderIndex)
		EndLoop
		Delete CHARACTER ,-1
		MoveCursorTo STARTOF DOCUMENT 
		Let OrderIndex=1
		Do "Print Totals"
	EndScript
	Routine "Type Calc Totals"
		If ATX="Tax"
			Type "Tax Payable : Tax="
			Type RightJustify(FormatValue(TotalTaxDistT,DefNote||"###0.00"),7)
			NewLine
			Type "Customer Tax: Tax="
			Type RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7)
		ElseIf ATX="GST"
			Type "Tax Payable : GST="
			Type RightJustify(FormatValue(TotalTaxDistG,DefNote||"###0.00"),7)
			NewLine
			Type "Customer Tax: GST="
			Type RightJustify(FormatValue(TotalTaxCustG,DefNote||"###0.00"),7)
		ElseIf ATX="PST"
			If ATC=2
				Type "Tax Payable : GST="
				Type RightJustify(FormatValue(TotalTaxDistG,DefNote||"###0.00"),7)
				Type "    Tax Payable : PST="
				Type RightJustify(FormatValue(TotalTaxDistP,DefNote||"###0.00"),7)
				NewLine
				Type "Customer Tax: GST="
				Type RightJustify(FormatValue(TotalTaxCustG,DefNote||"###0.00"),7)
				Type "    Customer Tax: PST="
				Type RightJustify(FormatValue(TotalTaxCustP,DefNote||"###0.00"),7)
			ElseIf ATC=1
				Type "    Tax Payable : PST="
				Type RightJustify(FormatValue(TotalTaxDistP,DefNote||"###0.00"),7)
				NewLine
				Type "    Customer Tax: PST="
				Type RightJustify(FormatValue(TotalTaxCustP,DefNote||"###0.00"),7)
			EndIf
		ElseIf ATX="VAT1"
			Type "Tax Payable : VAT1="
			Type RightJustify(FormatValue(TotalTaxDistV1,DefNote||"###0.00"),7)
			NewLine
			Type "Customer Tax: VAT1="
			Type RightJustify(FormatValue(TotalTaxCustV1,DefNote||"###0.00"),7)
		ElseIf ATX="VAT2"
			If ATC=2
				Type "Tax Payable : VAT1="
				Type RightJustify(FormatValue(TotalTaxDistV1,DefNote||"###0.00"),7)
				Type "    Tax Payable : VAT2="
				Type RightJustify(FormatValue(TotalTaxDistV2,DefNote||"###0.00"),7)
				NewLine
				Type "Customer Tax: VAT1="
				Type RightJustify(FormatValue(TotalTaxCustV1,DefNote||"###0.00"),7)
				Type "    Customer Tax: VAT2="
				Type RightJustify(FormatValue(TotalTaxCustV2,DefNote||"###0.00"),7)
			ElseIf ATC=1
				Type "    Tax Payable : VAT2="
				Type RightJustify(FormatValue(TotalTaxDistV2,DefNote||"###0.00"),7)
				NewLine
				Type "    Customer Tax: VAT2="
				Type RightJustify(FormatValue(TotalTaxCustV2,DefNote||"###0.00"),7)
			EndIf
		ElseIf ATX<>""
			Type "Tax Payable : Tax="
			Type RightJustify(FormatValue(TotalTaxDistT,DefNote||"###0.00"),7)
			NewLine
			Type "Customer Tax: Tax="
			Type RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7)
		ElseIf ATX=""
			Type "Tax Payable : Tax="
			Type RightJustify(FormatValue(TotalTaxDistT,DefNote||"###0.00"),7)
			NewLine
			Type "Tax="
			Type RightJustify(FormatValue(TotalTaxCustT,DefNote||"###0.00"),7)
		EndIf
	EndScript
	Routine "PrintTax"
		Let Day=GetWord(TheDate,2,"/")
		Let Month=GetWord(TheDate,1,"/")
		Let Year=GetWord(TheDate,3,"/")
		WorkWithDocument "Ram:AMWAYData/OrderData/Order.Doc"
		Clear DOCUMENT 
		Type " ",NEWLINE 
		Type "VS         Qty Description              P.V.     B.V. Tax     Dist    Cost"
		MoveCursorTo ENDOF DOCUMENT 
		NewLine
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
		InsertDocument "Order List"
		MoveCursorTo ENDOF DOCUMENT 
		NewLine
		Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
		Type "     Total Qty Total Profit  Total(s)   P.V.     B.V.         Dist    Cost",NEWLINE 
		Type "            "
		Type RightJustify(TotalQty,2)
		Type "      "
		Type RightJustify(FormatValue(TotalProfit,"###0.00"),7)
		Type "          "
		Type RightJustify(FormatValue(TotalPV,"###0.00"),7)
		Type "  "
		Type RightJustify(FormatValue(TotalBV,"###0.00"),7)
		Type "      "
		Type RightJustify(FormatValue(TotalDist,DefNote||"###0.00"),7)
		Type " "
		Type RightJustify(FormatValue(TotalCust,DefNote||"###0.00"),7),NEWLINE 
		NewLine
		Do "Type Calc Totals"
	EndScript
	Routine "Print"
		If T="Yes"
			Do "PrintTax"
		Else
			Let Day=GetWord(TheDate,2,"/")
			Let Month=GetWord(TheDate,1,"/")
			Let Year=GetWord(TheDate,3,"/")
			WorkWithDocument "Ram:AMWAYData/OrderData/Order.Doc"
			Clear DOCUMENT 
			Type " ",NEWLINE 
			Type "VS     Qty    Description              P.V.      B.V.      Dist      Cost"
			MoveCursorTo ENDOF DOCUMENT 
			NewLine
			Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
			InsertDocument "Order List"
			MoveCursorTo ENDOF DOCUMENT 
			NewLine
			Type "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ",NEWLINE 
			Type " Total Qty   Total Profit  Total(s)    P.V.      B.V.      Dist      Cost",NEWLINE 
			Type "      "
			Type RightJustify(TotalQty,3)
			Type "        "
			Type RightJustify(FormatValue(TotalProfit,Note||"####0.00"),8)
			Type "          "
			Type RightJustify(FormatValue(TotalPV,Note||"####0.00"),8)
			Type "  "
			Type RightJustify(FormatValue(TotalBV,Note||"####0.00"),8)
			Type "  "
			Type RightJustify(FormatValue(TotalDist,Note||"####0.00"),8)
			Type "  "
			Type RightJustify(FormatValue(TotalCust,Note||"####0.00"),8),NEWLINE 
		EndIf
		SaveDocument "Ram:AMWAYData/OrderData/Order.Doc"
		SaveDocument "Ram:AMWAYData/OrderData/Order.Doc","Ram:AMWAYData/PrintData/Order.Doc"
		Dos "C:Join Ram:AMWAYData/PrintData/Dist.Doc Ram:AMWAYData/PrintData/Order.Doc as Ram:AMWAYData/PrintData/Print.Doc"
		Dos "C:Copy Ram:AMWAYData/PrintData/Print.Doc to Ram:AMWAYData/OrderData/Temp.Doc"
		If DefDate="MDY"
			Dos "C:Rename Ram:AMWAYData/OrderData/Temp.Doc Ram:AMWAYData/OrderData/Ordering-["||Month||"-"||Day||"-"||Year||"].Doc"
		Else
			Dos "C:Rename Ram:AMWAYData/OrderData/Temp.Doc Ram:AMWAYData/OrderData/Ordering-["||Day||"-"||Month||"-"||Year||"].Doc"
		EndIf
		Dos "C:Delete Ram:AMWAYData/OrderData/Temp.Doc"
		Dos "C:Copy Ram:AMWAYData/OrderData "||DefOrdDir||" All"
	EndScript
	Window "UserWindow"
		Definition
			Origin 0,12
			Title "Ordering Screen..."
			WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR 
			Size 640,340
			DefaultColors 1,0,5
			WindowFlags ACTIVATE TOFRONT WORKBENCH 
			VisualEffects NONE ,WAIT 
		EndScript
		OnCloseButton
			Let OrderDataBase[OrderIndex]=GetDBObjects
			SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			GotoCard "DataBase Card"
		EndScript
	EndObject
	AreaButton "Info BarA"
		Definition
			Origin 7,20
			Image "AMWAYDeck:AMWAY.br/BarA.br"
			Highlight NONE 
		EndScript
	EndObject
	AreaButton "Info BarB"
		Definition
			Origin 297,20
			Image "AMWAYDeck:AMWAY.br/BarB.br"
			Highlight NONE 
		EndScript
	EndObject
	AreaButton "New Button"
		Definition
			Origin 7,37
			Image "AMWAYDeck:AMWAY.br/New.b0"
			AltImage "AMWAYDeck:AMWAY.br/New.b1"
		EndScript
		OnRelease
			SetDBObjects Nothing
			WorkWithDocument "Order List"
			Clear DOCUMENT 
			Dispose OrderDataBase
			Let OrderDataBase[OrderIndex]=GetDBObjects
			Do "Load DataFile"
			Do "Get Entry",1
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Previous Button"
		Definition
			Origin 45,37
			Image "AMWAYDeck:AMWAY.br/Prev.b0"
			AltImage "AMWAYDeck:AMWAY.br/Prev.b1"
		EndScript
		OnRelease
			Let Entry=GetDBObjects
			If Entry<>OrderDataBase[OrderIndex]
				DoObjectScript "Enter Button",ONRELEASE 
			EndIf
			Let OrderIndex=PreviousArrayIndex(OrderDataBase,OrderIndex)
			If Not SearchFound
				Let OrderIndex=LastArrayIndex(OrderDataBase)
			EndIf
			Do "Get Entry",OrderIndex
		EndScript
	EndObject
	AreaButton "Next Button"
		Definition
			Origin 152,37
			Image "AMWAYDeck:AMWAY.br/Next.b0"
			AltImage "AMWAYDeck:AMWAY.br/Next.b1"
		EndScript
		OnRelease
			Let Entry=GetDBObjects
			If Entry<>OrderDataBase[OrderIndex]
				DoObjectScript "Enter Button",ONRELEASE 
			EndIf
			Let OrderIndex=NextArrayIndex(OrderDataBase,OrderIndex)
			If Not SearchFound
				Let OrderIndex=FirstArrayIndex(OrderDataBase)
			EndIf
			Do "Get Entry",OrderIndex
		EndScript
	EndObject
	AreaButton "Load Button"
		Definition
			Origin 227,37
			Image "AMWAYDeck:AMWAY.br/Load.b0"
			AltImage "AMWAYDeck:AMWAY.br/Load.b1"
		EndScript
		OnRelease
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefOrdDir||"/.Data","Select File To Load...")
			If FileOf(FileName)<>""
				Let OrderDataBase=LoadVariable(FileName)
				Do "Load DataFile"
				SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			Else
				Let OrderIndex=1
				Let OrderDataBase[OrderIndex]=GetDBObjects
				Do "Load DataFile"
				SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			EndIf
			Do "Get Date"
			Do "Get Entry",1
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Save Button"
		Definition
			Origin 297,37
			Image "AMWAYDeck:AMWAY.br/Save.b0"
			AltImage "AMWAYDeck:AMWAY.br/Save.b1"
		EndScript
		OnRelease
			Let OrderDataBase[OrderIndex]=GetDBObjects
			SortArray OrderDataBase,INTEGER ,".VS"
			SaveVariable OrderDataBase,DefOrdDir||"/Order.Data"
			SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			If DefDate="MDY"
				SaveVariable OrderDataBase,DefOrdDir||"/Order-["||Month||"-"||Day||"-"||Year||"].Data"
				SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order-["||Month||"-"||Day||"-"||Year||"].Data"
			Else
				SaveVariable OrderDataBase,DefOrdDir||"/Order-["||Day||"-"||Month||"-"||Year||"].Data"
				SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order-["||Day||"-"||Month||"-"||Year||"].Data"
			EndIf
		EndScript
	EndObject
	AreaButton "Delete Button"
		Definition
			Origin 367,37
			Image "AMWAYDeck:AMWAY.br/Del.b0"
			AltImage "AMWAYDeck:AMWAY.br/Del.b1"
		EndScript
		OnRelease
			WorkWithDocument "Order List"
			If LinesInDocument=>1
				Do "Delete Entry",TheLineNumber
				Do "Get Entry",TheLineNumber
			EndIf
			Let OrderDataBase[OrderIndex]=GetDBObjects
			Do "Set Field",1
		EndScript
	EndObject
	AreaButton "Customer Button"
		Definition
			Origin 437,37
			Image "AMWAYDeck:AMWAY.br/CR.b0"
			AltImage "AMWAYDeck:AMWAY.br/CR.b1"
		EndScript
		OnRelease
			Let OrderDataBase[OrderIndex]=GetDBObjects
			SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			GotoCard "Customer Card"
		EndScript
	EndObject
	AreaButton "Enter Button"
		Definition
			Origin 0,0
			Highlight NONE 
			Size 1,1
		EndScript
		OnRelease
			WorkWithDocument "Stock List"
			Let L=TheLineNumber
			Do "Store Entry"
			Do "Get Entry",L
			Do "Set Field",CurrField
		EndScript
	EndObject
	TextField ".VS"
		Definition
			InitialText ""
			Origin 9,73
			Size 88,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 11
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=1
		EndScript
		OnRelease
			Let VS=TextFrom(".VS")
			Do "Set Field",3
		EndScript
	EndObject
	IntegerField ".Qty"
		Definition
			Limits 1,99
			InitialInteger 1
			Origin 103,73
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 2
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=2
		EndScript
		OnRelease
			Let Qty=IntegerFrom(".Qty")
			Do "Set Field",3
		EndScript
	EndObject
	TextField ".Des"
		Definition
			InitialText ""
			Origin 133,73
			Size 160,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			MaxFieldLength 20
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=3
		EndScript
		OnRelease
			Let Des=TextFrom(".Des")
			Do "Set Field",4
		EndScript
	EndObject
	TextField ".PV"
		Definition
			InitialText ""
			Origin 299,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=4
		EndScript
		OnRelease
			Do "Format Fields","PV",PV
			Do "Set Field",5
		EndScript
	EndObject
	TextField ".BV"
		Definition
			InitialText ""
			Origin 369,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=5
		EndScript
		OnRelease
			Do "Format Fields","BV",BV
			Do "Set Field",6
		EndScript
	EndObject
	TextField ".Tax"
		Definition
			InitialText ""
			Origin 439,73
			Size 24,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 4
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=6
		EndScript
		OnRelease
			Do "Set Field",7
		EndScript
	EndObject
	TextField ".Dist"
		Definition
			InitialText ""
			Origin 469,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=7
		EndScript
		OnRelease
			Do "Format Fields","Dist",Dist
			Do "Set Field",8
		EndScript
	EndObject
	TextField ".Cust"
		Definition
			InitialText ""
			Origin 539,73
			Size 64,12
			Border BEVEL ,4,2 ; BorderStyle, MainPen, ExtraPen
			Justification RIGHT 
			MaxFieldLength 7
			Font "topaz",8 ; FontName, PointSize
			TextColors 1,5 ; PenA, PenB, DrawMode
			AltTextColors 1,5
		EndScript
		OnClick
			Let CurrField=8
		EndScript
		OnRelease
			Do "Format Fields","Cust",Cust
			Let Entry=GetDBObjects
			If Entry<>StockDataBase[StockIndex]
				DoObjectScript "Enter Button",ONRELEASE 
			EndIf
			Do "Set Field",1
		EndScript
	EndObject
	List "OrdDoc"
		Definition
			ListDocument "Order List" ; where the text comes from
			Origin 9,93
			Size 622,168
			Border INVERT BEVEL  ; BorderStyle, MainPen, ExtraPen
			Font "topaz",8 ; FontName, PointSize
		EndScript
		OnRelease
			WorkWithDocument "Order List"
			Do "Get Entry",TheLineNumber
			Do "Set Field",CurrField
		EndScript
	EndObject
	TextMenu "New"
		Definition
			AttachTo MENU ,"Project..."
			Text "New..."
			ShortCutKey "N"
		EndScript
		Occurred
			DoObjectScript "New Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Load"
		Definition
			AttachTo MENU ,"Project..."
			Text "Load..."
			ShortCutKey "L"
		EndScript
		Occurred
			DoObjectScript "Load Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Save"
		Definition
			AttachTo MENU ,"Project..."
			Text "Save..."
			ShortCutKey "S"
		EndScript
		Occurred
			DoObjectScript "Save Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Save As"
		Definition
			AttachTo MENU ,"Project..."
			Text "Save As..."
			ShortCutKey "A"
		EndScript
		Occurred
			SetFileRequestMode REGULARMODE ,REJECTICONS PATTERNFIELD 
			SetFileRequestPattern "#?.Data"
			Let FileName=AskForFileName(DefOrdDir||"/Order.Data","Select File To Load...")
			If FileOf(FileName)<>Nothing
				SaveVariable StockDataBase,FileName
				SaveVariable StockDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			Else
				Let OrderDataBase[OrderIndex]=GetDBObjects
			EndIf
		EndScript
	EndObject
	TextMenu "Previous"
		Definition
			AttachTo MENU ,"Project..."
			Text "Previous..."
			ShortCutKey "<"
		EndScript
		Occurred
			DoObjectScript "Previous Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Next"
		Definition
			AttachTo MENU ,"Project..."
			Text "Next..."
			ShortCutKey ">"
		EndScript
		Occurred
			DoObjectScript "Next Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Delete"
		Definition
			AttachTo MENU ,"Project..."
			Text "Delete..."
			ShortCutKey "D"
		EndScript
		Occurred
			DoObjectScript "Delete Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Find"
		Definition
			AttachTo MENU ,"Project..."
			Text "Find..."
			ShortCutKey "F"
		EndScript
		Occurred
			DoObjectScript "Search Button",ONRELEASE 
		EndScript
	EndObject
	TextMenu "Distributor"
		Definition
			AttachTo MENU ,"Project..."
			Text "Distributor..."
			ShortCutKey "T"
		EndScript
		Occurred
			Let OrderDataBase[OrderIndex]=GetDBObjects
			SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			GotoCard "Distributor Card"
			
		EndScript
	EndObject
	TextMenu "DataBase"
		Definition
			AttachTo MENU ,"Project..."
			Text "DataBase..."
			ShortCutKey "B"
		EndScript
		Occurred
			Let OrderDataBase[OrderIndex]=GetDBObjects
			SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			GotoCard "DataBase Card"
			
		EndScript
	EndObject
	TextMenu "Customer"
		Definition
			AttachTo MENU ,"Project..."
			Text "Customer..."
			ShortCutKey "C"
		EndScript
		Occurred
			Let OrderDataBase[OrderIndex]=GetDBObjects
			SaveVariable OrderDataBase,"Ram:AMWAYData/OrderData/Order.Data"
			GotoCard "Reciet Card"
			
		EndScript
	EndObject
	TextMenu "Print"
		Definition
			AttachTo MENU ,"Project..."
			Text "Print..."
			ShortCutKey "P"
		EndScript
		Occurred
			SaveDocument "Stock List","Ram:AMWAYData/PrintData/Stock.list"
			Dos "C:Copy Ram:AMWAYData/PrintData/Stock.list PRT:"
		EndScript
	EndObject
	TextMenu "Quit"
		Definition
			AttachTo MENU ,"Project..."
			Text "Quit..."
			ShortCutKey "Q"
		EndScript
		Occurred
			Do "Quit"
		EndScript
	EndObject
	AreaButton "Print Button"
		Definition
			Origin 607,37
			Image "AMWAYDeck:AMWAY.br/Prt.b0"
			AltImage "AMWAYDeck:AMWAY.br/Prt.b1"
		EndScript
		OnRelease
			Do "Print"
			Dos "C:Copy Ram:AMWAYData/PrintData/Print.Doc Prt:"
		EndScript
	EndObject
	AreaButton "VS Button"
		Definition
			Origin 7,55
			Image "AMWAYDeck:AMWAY.br/VS.b0"
			AltImage "AMWAYDeck:AMWAY.br/VS.b1"
		EndScript
		OnRelease
			SetText ".VS",""
			SetObjectState ".VS",On
		EndScript
	EndObject
	AreaButton "Search Button"
		Definition
			Origin 44,55
			Image "AMWAYDeck:AMWAY.br/Ser.b0"
			AltImage "AMWAYDeck:AMWAY.br/Ser.b1"
		EndScript
		OnRelease
			OpenWindow "AMWAYSubDeck","List Stock","Do Search",SearchText,SearchField
		EndScript
	EndObject
	AreaButton "Qty + Button"
		Definition
			Origin 100,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Get VS"
			Do "Tax"
			Do "Tax Amounts"
			Let OrderDataBase[OrderIndex]=GetDBObjects
			Let SearchText=TextFrom(".VS")
			Let SearchField="VS"
			Do "Search Next"
			DoObjectScript "Enter Button",ONRELEASE 
			Do "Search Next"
			Do "Set Field",2
		EndScript
		OnClick
			Do "Get VS"
			While ObjectState("Qty + Button")
				Let Qty=IntegerFrom(".Qty")
				Let Qty=Qty+1
				If Qty>99
					Let Qty=1
				EndIf
				Let PV=FormatValue(Qty*StockDataBase[StockIndex].PV,"###0.00")
				Let BV=FormatValue(Qty*StockDataBase[StockIndex].BV,"###0.00")
				Let Dist=FormatValue(Qty*StockDataBase[StockIndex].Dist,"###0.00")
				Let Cust=FormatValue(Qty*StockDataBase[StockIndex].Cust,"###0.00")
				Delay 0,0,10
				SetInteger ".Qty",Qty
				SetText ".PV",PV
				SetText ".BV",BV
				SetText ".Dist",Dist
				SetText ".Cust",Cust
			EndLoop
		EndScript
	EndObject
	AreaButton "Qty - Button"
		Definition
			Origin 115,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			DoObjectScript "Qty + Button",ONRELEASE 
		EndScript
		OnClick
			Do "Get VS"
			While ObjectState("Qty - Button")
				Let Qty=IntegerFrom(".Qty")
				Let Qty=Qty-1
				If Qty=0
					Let Qty=99
				EndIf
				Let PV=FormatValue(Qty*StockDataBase[StockIndex].PV,"###0.00")
				Let BV=FormatValue(Qty*StockDataBase[StockIndex].BV,"###0.00")
				Let Dist=FormatValue(Qty*StockDataBase[StockIndex].Dist,"###0.00")
				Let Cust=FormatValue(Qty*StockDataBase[StockIndex].Cust,"###0.00")
				Delay 0,0,10
				SetInteger ".Qty",Qty
				SetText ".PV",PV
				SetText ".BV",BV
				SetText ".Dist",Dist
				SetText ".Cust",Cust
			EndLoop
		EndScript
	EndObject
	AreaButton "Des Button"
		Definition
			Origin 131,55
			Image "AMWAYDeck:AMWAY.br/Des.b0"
			AltImage "AMWAYDeck:AMWAY.br/Des.b1"
		EndScript
		OnRelease
			SetText ".Des",""
			Do "Set Field",3
		EndScript
	EndObject
	AreaButton "PV + Button"
		Definition
			Origin 297,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Set Field",4
		EndScript
		OnClick
			Do "Format $","PV + Button",Max(99999),PV,"PV","+",">",0
		EndScript
	EndObject
	AreaButton "PV Button"
		Definition
			Origin 311,55
			Image "AMWAYDeck:AMWAY.br/PV.b0"
			AltImage "AMWAYDeck:AMWAY.br/PV.b1"
		EndScript
		OnRelease
			SetText ".PV",""
			Do "Set Field",4
		EndScript
	EndObject
	AreaButton "PV - Button"
		Definition
			Origin 350,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			Do "Set Field",4
		EndScript
		OnClick
			Do "Format $","PV - Button",Min(0),PV,"PV","-","<",99999
		EndScript
	EndObject
	AreaButton "BV + Button"
		Definition
			Origin 367,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Set Field",5
		EndScript
		OnClick
			Do "Format $","BV + Button",Max(99999),BV,"BV","+",">",0
		EndScript
	EndObject
	AreaButton "BV Button"
		Definition
			Origin 381,55
			Image "AMWAYDeck:AMWAY.br/BV.b0"
			AltImage "AMWAYDeck:AMWAY.br/BV.b1"
		EndScript
		OnRelease
			SetText ".BV",""
			Do "Set Field",5
		EndScript
	EndObject
	AreaButton "BV - Button"
		Definition
			Origin 420,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			Do "Set Field",5
		EndScript
		OnClick
			Do "Format $","BV - Button",Min(0),BV,"BV","-","<",99999
		EndScript
	EndObject
	AreaButton "Tax Button"
		Definition
			Origin 437,55
			Image "AMWAYDeck:AMWAY.br/Tax.b0"
			AltImage "AMWAYDeck:AMWAY.br/Tax.b1"
		EndScript
		OnRelease
			OpenWindow "AMWAYSubDeck","Tax Card","Set Tax Field",SearchText,SearchField
		EndScript
	EndObject
	AreaButton "Dist + Button"
		Definition
			Origin 467,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Set Field",7
		EndScript
		OnClick
			Do "Format $","Dist + Button",Max(99999),Dist,"Dist","+",">",0
		EndScript
	EndObject
	AreaButton "Dist Button"
		Definition
			Origin 481,55
			Image "AMWAYDeck:AMWAY.br/Dist.b0"
			AltImage "AMWAYDeck:AMWAY.br/Dist.b1"
		EndScript
		OnRelease
			SetText ".Dist",""
			Do "Set Field",7
		EndScript
	EndObject
	AreaButton "Dist - Button"
		Definition
			Origin 520,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			Do "Set Field",7
		EndScript
		OnClick
			Do "Format $","Dist - Button",Min(0),Dist,"Dist","-","<",9999
		EndScript
	EndObject
	AreaButton "Cust + Button"
		Definition
			Origin 537,55
			Image "AMWAYDeck:AMWAY.br/+.b0"
			AltImage "AMWAYDeck:AMWAY.br/+.b1"
		EndScript
		OnRelease
			Do "Set Field",8
		EndScript
		OnClick
			Do "Format $","Cust + Button",Max(99999),Cust,"Cust","+",">",0
		EndScript
	EndObject
	AreaButton "Cust Button"
		Definition
			Origin 551,55
			Image "AMWAYDeck:AMWAY.br/Cost.b0"
			AltImage "AMWAYDeck:AMWAY.br/Cost.b1"
		EndScript
		OnRelease
			SetText ".Cust",""
			Do "Set Field",8
		EndScript
	EndObject
	AreaButton "Cust - Button"
		Definition
			Origin 590,55
			Image "AMWAYDeck:AMWAY.br/-.b0"
			AltImage "AMWAYDeck:AMWAY.br/-.b1"
		EndScript
		OnRelease
			Do "Set Field",8
		EndScript
		OnClick
			Do "Format $","Cust - Button",Min(0),Cust,"Cust","-","<",99999
		EndScript
	EndObject
* End of Card "Ordering Card"
*************

*************
* 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"
*************

