Hi
This topic has been discussed extensively but I can’t find the answer I need - so if you can point me to the right thread that would be great. I have a table where the values are stored in text strings and I use several buttons to add, modify and delete. I have added the code from one button to show you quite how many times I use @Subset. I am getting the “second argument to @Subset cannot be zero”. I have tried using @Statusbar and @Prompt without success to try to find where the error is occurring. Can someone please tell me how to find the error(s) or specifically what code I need to add and where in order to error check it.
Many thanks
Tim
tnorris@notesafrica.co.za
=========================
replicaid:=“C1256870:003CDA3C”;
telemRT := @Elements(OItemNumber);
@If(telemRT; “”; @Return(“”));
tNewQty := “”;
tNewDesc := “”;
tNewFreq := “”;
tItemNo := “”;
tItemSearch0 := “”;
tItemDescription := “”;
tItemFrequency := “”;
tItemSearch := “”;
tSLP := “”;
tDisc := “”;
tDisc0 := “”;
tPrice0 := “”;
tPrice := “”;
tList := OItemNumber + " " + ODescription + " - Qty: " + @Text(OQuantity);
tA := “0” : “1” : “2” : “3” : “4” : “5” : “6” : “7” : “8” : “9”;
tB := tA *+ tA;
tB2 := @Subset(tB; -99);
tPopupList := @Subset(tB2; telemRT) + ". " + tList;
tselection := @Prompt([OkCancelList]; “Modify Item”; “Select the item you wish to modify:”; @Subset(tPopupList; 1); tPopupList);
@If(tselection = “”; @Return(“”); “”);
tChoice := @Member(tselection; tPopupList);
tNbrElements := @Elements(tPopupList);
tWhat := @Prompt([OkCancelList]; “Modify Field”; "Select the field you wish to modify for Item " + @Subset(@Subset(OItemNumber; tChoice); -1); “List Price”; “Item Number” : “Item Description” : “Quantity” : “List Price” : “Discount”: “Replacement Frequency”);
@If(tWhat = “Quantity”;
@Do(@Set(“tNewQty”; @TextToNumber(@Prompt([OkCancelEdit]; “New Quantity”; “Enter new quantity”; @Text(@Subset(@Subset(OQuantity; tChoice); -1)))));
@If(@IsNumber(tNewQty) & tNewQty > 0; “”; @Do(@Prompt([Ok]; “Error”; “The quantity entered is not a valid number ! " + @Text(tNewQty)); @Return(”")) );
@If(tChoice = 1; @SetField(“OQuantity”; tNewQty : @Subset(OQuantity; 1 - tNbrElements));
tChoice = tNbrElements; @SetField(“OQuantity”; @Subset(OQuantity; tChoice - 1) : tNewQty);
@SetField(“OQuantity”; @Subset(OQuantity; tChoice - 1) : tNewQty : @Subset(OQuantity; tChoice - tNbrElements))));
tWhat = “Replacement Frequency”; @Do(@Set(“tNewFreq”; @TextToNumber(@Prompt([OkCancelEdit]; “New Replacement Frequency”; “Enter new Frequency”; @Text(@Subset(@Subset(OFrequency; tChoice); -1)))));
@If(@IsError(tNewFreq); @Do(@Prompt([Ok]; “Error”; “The frequency you entered is not a valid number ! " + @Text(tNewFreq) + “. Click OK and repeat the procedure”); @Return(”")); “”);
@If(tChoice = 1; @SetField(“OFrequency”; tNewFreq : @Subset(OFrequency; 1 - tNbrElements));
tChoice = tNbrElements; @SetField(“OFrequency”; @Subset(OFrequency; tChoice - 1) : tNewFreq);
@SetField(“OFrequency”; @Subset(OFrequency; tChoice - 1) : tNewFreq : @Subset(OFrequency; tChoice - tNbrElements))));
tWhat = “List Price”;
@Do(@Set(“tSLP”; @TextToNumber(@Prompt([OkCancelEdit]; “New Item List Price”; “Enter new Item List Price”; @Text(@Subset(@Subset(OListPrice; tChoice); -1)))));
@If(@IsError(tSLP); @Do(@Prompt([Ok]; “Error”; “The List Price you entered is not a valid number ! - " + @Text(tSLP) + “. Click OK and repeat the procedure”); @Return(”")); “”);
@Set(“tPrice”; tSLP * (1 - @Subset(@Subset(ODiscount; tChoice); -1)));
@If(tChoice = 1; @Do(@SetField(“OListPrice”; tSLP : @Subset(OListPrice; 1 - tNbrElements));
@SetField(“OPrice”; tPrice : @Subset(OPrice; 1 - tNbrElements)) );
tChoice = tNbrElements; @Do(@SetField(“OListPrice”; @Subset(OListPrice; tChoice - 1) : tSLP);
@SetField(“OPrice”; @Subset(OPrice; tChoice - 1) : tPrice) );
@Do(@SetField(“OListPrice”; @Subset(OListPrice; tChoice - 1) : tSLP : @Subset(OListPrice; tChoice - tNbrElements));
@SetField(“OPrice”; @Subset(OPrice; tChoice - 1) : tPrice : @Subset(OPrice; tChoice - tNbrElements))) ) );
tWhat = “Discount”; @Do(@Set(“tDisc0”; @TextToNumber(@Prompt([OkCancelEdit]; “New Discount”; “Enter new Discount (eg 20 for 20%)”; @Text(100 * @Subset(@Subset(ODiscount; tChoice); -1)))));
@If(@IsError(tDisc0) ; @Do(@Prompt([Ok]; “Error”; “The Discount you entered is not a valid number ! " + @Text(tDisc0) + “. Click OK and repeat the procedure”); @Return(”")); “”);
@Set(“tDisc”; tDisc0 / 100);
@Set(“tListPrice”; @Subset(@Subset(OListPrice; tChoice); -1));
@Set(“tPrice”; (1- tDisc) * tListPrice);
@If(tChoice = 1; @Do(@SetField(“ODiscount”; tDisc : @Subset(ODiscount; 1 - tNbrElements));
@SetField(“OPrice”; tPrice : @Subset(OPrice; 1 - tNbrElements)) );
tChoice = tNbrElements; @Do(@SetField(“ODiscount”; @Subset(ODiscount; tChoice - 1) : tDisc);
@SetField(“OPrice”; @Subset(OPrice; tChoice - 1) : tPrice) );
@Do(@SetField(“ODiscount”; @Subset(ODiscount; tChoice - 1) : tDisc : @Subset(ODiscount; tChoice - tNbrElements));
@SetField(“OPrice”; @Subset(OPrice; tChoice - 1) : tPrice : @Subset(OPrice; tChoice - tNbrElements))) ) );
tWhat = “Item Description”; @Do(@Set(“tNewDesc”; @Prompt([OkCancelEdit]; “Description”; “Enter new description”; @Subset(@Subset(ODescription; tChoice); -1))); @If(tChoice = 1; @SetField(“ODescription”; tNewDesc : @Subset(ODescription; 1 - tNbrElements)); tChoice = tNbrElements; @SetField(“ODescription”; @Subset(ODescription; tChoice - 1) : tNewDesc); @SetField(“ODescription”; @Subset(ODescription; tChoice - 1) : tNewDesc : @Subset(ODescription; tChoice - tNbrElements))));
tWhat = “Item Number”; @Do(@Set(“tItemNo”; @UpperCase(@Trim(@Prompt([OkCancelEdit]; “Item Number”; “Enter new item number:”; “”)))); @If(tItemNo = “”; @Return(@Prompt([Ok]; “Re-enter Item Number”; “Item Number must be entered. Please click OK and repeat the procedure”)); “”);
@Set(“tItemSearch0”; @DbLookup(“”; replicaid; “(SearchByItemNumber)”; tItemNo; 2)); @Set(“tItemDescription”; @If(@IsError(tItemSearch0) | tItemSearch0 = “”; @Left(@UpperCase(@Trim(@Prompt([OkCancelEdit]; “Description”; "Please enter Description for Item " + tItemNo; tItemDescription))); 32); @Do(@Prompt([Ok]; “Item description”; tItemSearch0); @Text(tItemSearch0))));
@Set(“tItemSearch1”; @DbLookup(“”; replicaid; “(SearchByItemNumber)”; tItemNo; 4)); @Set(“tItemFrequency”; @If(@IsError(tItemSearch1) | tItemSearch1 = “”; @Left(@UpperCase(@Trim(@Prompt([OkCancelEdit]; “Replacement Frequency (Months)”; "Please enter Frequency for Item " + tItemNo; tItemFrequency))); 32); @Do(@Prompt([Ok]; “Standard Replacement Frequency (Months)”; “The Standard Replacement Frequency for this Item is set at " + @Text(tItemSearch1) + " months”); tItemSearch1)));
@Set(“tItemSearch”; @DbLookup(“”; replicaid; “(SearchByItemNumber)”; tItemNo; 3)); @Set(“tListPrice”; @If(@IsError(tItemSearch) | tItemSearch = “”; @TextToNumber(@Prompt([OkCancelEdit]; “Item List Price”; “Enter the Item List Price for " + tItemNo; “”)); @Do(@Prompt([Ok]; “Item List Price”; @Text(tItemSearch; “F,2”)); tItemSearch))); @If(@IsNumber(tListPrice) & tListPrice > 0; “”; @Do(@Prompt([Ok]; “Re-Enter List Price”; “The List Price entered must be a valid number. Please click OK and repeat the procedure.”); @Return(”")));
@Do(@Set(“tDisc0”; @TextToNumber(@Prompt([OkCancelEdit]; “Enter Discount”; “Enter new Discount (eg 20 for 20%)”; @Text(100 * @Subset(@Subset(ODiscount; tChoice); -1)))));
@If(@IsError(tDisc0) ; @Do(@Prompt([Ok]; “Error”; “The Discount you entered is not a valid number ! " + @Text(tDisc0) + “. Click OK and repeat the procedure”); @Return(”")); “”);
@Set(“tDisc”; tDisc0 / 100);
@Set(“tListPrice”; @Subset(@Subset(OListPrice; tChoice); -1));
@Set(“tPrice”; (1- tDisc) * tListPrice));
@If(tChoice = 1; @Do(@SetField(“OItemNumber”; tItemNo : @Subset(OItemNumber; 1 - tNbrElements)); @SetField(“ODescription”; tItemDescription : @Subset(ODescription; 1 - tNbrElements)); @SetField(“OListPrice”; tListPrice : @Subset(OListPrice; 1 - tNbrElements)); @SetField(“ODiscount”; tDisc : @Subset(ODiscount; 1- tNbrElements));@SetField(“OPrice”; tPrice : @Subset(OPrice; 1 - tNbrElements)) );
tChoice = tNbrElements; @Do(@SetField(“OItemNumber”; @Subset(OItemNumber; tChoice - 1) : tItemNo); @SetField(“ODescription”; @Subset(ODescription; tChoice - 1) : tItemDescription);
@SetField(“OListPrice”; @Subset(OListPrice; tChoice - 1) : tListPrice); @SetField(“ODiscount”; @Subset(ODiscount; tChoice - 1) : tDisc); @SetField(“OPrice”; @Subset(OPrice; tChoice - 1) : tPrice));
@Do(@SetField(“OItemNumber”; @Subset(OItemNumber; tChoice - 1) : tItemNo : @Subset(OItemNumber; tChoice - tNbrElements)); @SetField(“ODescription”; @Subset(ODescription; tChoice - 1) : tItemDescription : @Subset(ODescription; tChoice - tNbrElements));
@SetField(“OListPrice”; @Subset(OListPrice; tChoice - 1) : tListPice : @Subset(OListPrice; tChoice - tNbrElements)); @SetField(“ODiscount”; @Subset(ODiscount; tChoice - 1) : tDisc : @Subset(ODiscount; tChoice - tNbrElements));
@SetField(“OPrice”; @Subset(OPrice; tChoice - 1) : tPrice : @Subset(OPrice; tChoice - tNbrElements))))); “”);
@PostedCommand([ViewRefreshFields])