Tip

Work Fields With Multivalue In Formula - Dynamic Table

tree button for work with fields multivalues in a table (script is not
requerid)
3 buttom (add, Change, Del)
the form has tree (3) field (multivalues) Field01, Field02, Field03
the form (dialogbox1) has tree fields (HField01, HField02, HField03)
ADD
FIELD HField01 := "" ;
FIELD HField02 := "" ;
FIELD HField03 := "" ;
okcancel := @DialogBox( "DialogBox1" ; [AutoHorzFit] : [AutoVertFit] ; "Add
Information") ;
@If(okcancel = 0; @Return("") ; @Success) ;
FIELD Field01 := @If(Field01 = "" ; HField01 ; Field01 : HField01) ;
FIELD Field02 := @Trim(Field02 : HField02) ;
FIELD Field03:= @If(Field03 = "" ; HField03 ; Field03 : HField03 ) ;

CHANGE
FIELD HField01 := "" ;
FIELD HField02 := "" ;
FIELD HField03 := "" ;
@If(@Elements(Field01) = 0; @Return(@Prompt([OK]; "Error "; "No rows for
change. Process Cancel.")); @Success);
numbers := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9";
LineItem := @Subset(@Subset(@Text(@TextToNumber(numbers *+ numbers)); -99);
@Elements(Field01));
ModElement := @Prompt([OKCANCELLIST] : [NoSort]; "Modificar Fila"; "Choice a
row for change; @Subset(LineItem; 1) + ". " + @Subset(@Text(Field01);1);
LineItem + ". " + @Text(Field01) + " " + Field02);
@If(@IsError(@Trim(ModElement)); @Return(@Prompt([OK]; "Error "; "Don?t choice
a row. Process cancel.")); @Success);
Selection := @TextToNumber(@Word(ModElement;". ";1));
FIELD HField01 := @Subset(@Subset(Field01; Selection); -1);
FIELD HField02 := @Subset(@Subset(Field02; Selection); -1);
FIELD HField03 := @Subset(@Subset(Field03; Selection); -1);
okcancel := @DialogBox("DialogBox1"; [AutoHorzFit] : [AutoVertFit];"Change
information" );
@If(okcancel = 0; @Return(""); @Success);
PlaceInList := @Member(@Text(Selection); LineItem);
FirstElementsNum := PlaceInList - 1;
LastElementsNum := (@Elements(LineItem) - PlaceInList) * -1 ;
FirstA := @If(FirstElementsNum = 0; ""; @Subset(Field01; FirstElementsNum));
LastA := @If(LastElementsNum = 0; ""; @Subset(Field01; LastElementsNum));
FIELD Field01 := @If (FirstA = "" ; HField01 : LastA ; LastA = "" ; FirstA :
HField01 ; FirstA : HField01 : LastA ) ;
FirstB := @If(FirstElementsNum = 0; ""; @Subset(Field02; FirstElementsNum));
LastB := @If(LastElementsNum = 0; ""; @Subset(Field02; LastElementsNum));
FIELD Field02 := @Trim(FirstB : HField02 : LastB);
FirstC := @If(FirstElementsNum = 0; ""; @Subset(Field03; FirstElementsNum));
LastC := @If(LastElementsNum = 0; ""; @Subset(Field03; LastElementsNum));
FIELD Field03 := @If (FirstC = "" ; HField03 : LastC ; LastC = "" ; FirstC :
HField03 ; FirstC : HField03 : LastC ) ;
""

DEL

@If(@Elements(Field01) = 0; @Return(@Prompt([OK]; "Error "; "No rows for
delete. Process cancel.")); @Success);
numbers := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9";
LineItem := @Subset(@Subset(@Text(@TextToNumber(numbers *+ numbers)); -99);
@Elements(Field01));
DeleteElement := @Prompt([OKCANCELLIST]; "Del row"; "Choice a row for delete:
"; @Subset(LineItem; 1) + ". " + @Subset(@Text(Field01);1); LineItem + ". " +
@Text(Field01));
@If(@IsError(@Trim(DeleteElement)); @Return(@Prompt([OK]; "Error "; "Don?t
choice a row. Process cancel.")); @Success);
Selection := @TextToNumber(@Word(DeleteElement;". ";1));
PlaceInList := Selection;
FirstElementsNum := PlaceInList - 1;
LastElementsNum := (@Elements(LineItem) - PlaceInList) * -1;
FirstA := @If(FirstElementsNum = 0; ""; @Subset(Field01; FirstElementsNum));
LastA := @If(LastElementsNum = 0; ""; @Subset(Field01; LastElementsNum));
FIELD Field01 := @If (FirstA = "" ; LastA ; LastA = "" ; FirstA ; FirstA :
LastA ) ;
FirstB := @If(FirstElementsNum = 0; ""; @Subset(Field02; FirstElementsNum));
LastB := @If(LastElementsNum = 0; ""; @Subset(Field02; LastElementsNum));
FIELD Field02 := @Trim(FirstB : LastB);
FirstC := @If(FirstElementsNum = 0; ""; @Subset(Field03; FirstElementsNum));
LastC := @If(LastElementsNum = 0; ""; @Subset(Field03; LastElementsNum));
FIELD Field03 := @If (FirstC = "" ; LastC ; LastC = "" ; FirstC ; FirstC :
LastC ) ;
""

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.