Hola a todos,
Actualmente estoy tratando de crear un script que creará columnas en una tabla de datos según las entradas del usuario. Primero le pedirá al usuario el nombre de la columna, luego analizará los nombres en las columnas en diferentes caracteres dependiendo de las entradas del usuario. Tengo problemas con la evaluación de obtención si hay menos de 7 opciones seleccionadas en el cuadro combinado. Actualmente recibo el error de que los cuadros eliminados no se pueden evaluar como 'Pegamento'. ¿Hay alguna forma de evitar esto? Probé la función de prueba y me dio algunos valores extraños.
Gracias,
Andy
clearlog();
dt = Current Data Table();
nc = ncol(dt);
New Window("SID parser",
H List Box("Main Box",
V List Box("VLISTBOXcolumn names",
PanelBox("Select Column",
colListData=ColListBox(All,nLines(min(nc,10)))
), //end panel box
), // end VLISTBOXcolumn names
V List Box("VLISTBOXDIGITS",
Text Box("Select Number of Columns"),
x = Combo Box( {"1", "2","3","4","5","6","7"},
<< set function( Function( {this},
value = this << get;
If(
value == 1,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend(
V List Box(
H List Box(
Text Box("Number of Characters"),
y = Number Edit Box(2,4),
Text Box("Column Name"),
z = Text Edit Box("Protocol"),
z << set width(100),
) // end 1st column HLISTBOX
)
),
value == 2,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend( // add new box
V List Box(
H List Box(
Text Box("Number of Characters"),
y = Number Edit Box(2,4),
Text Box("Column Name"),
z = Text Edit Box("Protocol"),
z << set width(100),
), // end 1st column HLISTBOX
H List Box(
Text Box("Number of Characters"),
y2 = Number Edit Box(3,4),
Text Box("Column Name"),
z2 = Text Edit Box("Optional"),
z2 << set width(100),
) // end 2nd column h list box
) //end VLISTBOX
), // end sib append
value == 3,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend( // add new box
V List Box(
H List Box(
Text Box("Number of Characters"),
y = Number Edit Box(2,4),
Text Box("Column Name"),
z = Text Edit Box("Protocol"),
z << set width(100),
), // end 1st column HLISTBOX
H List Box(
Text Box("Number of Characters"),
y2 = Number Edit Box(3,4),
Text Box("Column Name"),
z2 = Text Edit Box("Optional"),
z2 << set width(100),
), // end 2nd column h list box
H List Box(
Text Box("Number of Characters"),
y3 = Number Edit Box(3,4),
Text Box("Column Name"),
z3 = Text Edit Box("Tube Type"),
z3 << set width(100),
), // end 3rd column h list box
) //end VLISTBOX
), // end sib append
value == 4,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend( // add new box
V List Box(
H List Box(
Text Box("Number of Characters"),
y = Number Edit Box(2,4),
Text Box("Column Name"),
z = Text Edit Box("Protocol"),
z << set width(100),
), // end 1st column HLISTBOX
H List Box(
Text Box("Number of Characters"),
y2 = Number Edit Box(3,4),
Text Box("Column Name"),
z2 = Text Edit Box("Optional"),
z2 << set width(100),
), // end 2nd column h list box
H List Box(
Text Box("Number of Characters"),
y3 = Number Edit Box(3,4),
Text Box("Column Name"),
z3 = Text Edit Box("Tube Type"),
z3 << set width(100),
), // end 3rd column h list box
H List Box(
Text Box("Number of Characters"),
y4 = Number Edit Box(3,4),
Text Box("Column Name"),
z4 = Text Edit Box("Sample Number"),
z4 << set width(100),
), // end 4th column h list box
), //end VLISTBOX
), // end sib append
value == 5,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend( // add new box
V List Box(
H List Box(
Text Box("Number of Characters"),
y = Number Edit Box(2,4),
Text Box("Column Name"),
z = Text Edit Box("Protocol"),
z << set width(100),
), // end 1st column HLISTBOX
H List Box(
Text Box("Number of Characters"),
y2 = Number Edit Box(1,4),
Text Box("Column Name"),
z2 = Text Edit Box("Optional"),
z2 << set width(100),
), // end 2nd column h list box
H List Box(
Text Box("Number of Characters"),
y3 = Number Edit Box(3,4),
Text Box("Column Name"),
z3 = Text Edit Box("Tube Type"),
z3 << set width(100),
), // end 3rd column h list box
H List Box(
Text Box("Number of Characters"),
y4 = Number Edit Box(3,4),
Text Box("Column Name"),
z4 = Text Edit Box("Sample Number"),
z4 << set width(100),
), // end 4th column h list box
H List Box(
Text Box("Number of Characters"),
y5 = Number Edit Box(1,4),
Text Box("Column Name"),
z5 = Text Edit Box("Analyte Level"),
z5 << set width(100),
), // end 5th column h list box
), //end VLISTBOX
), // end sib append
value == 6,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend( // add new box
V List Box(
H List Box(
Text Box("Number of Characters"),
y = Number Edit Box(2,4),
Text Box("Column Name"),
z = Text Edit Box("Protocol"),
z << set width(100),
), // end 1st column HLISTBOX
H List Box(
Text Box("Number of Characters"),
y2 = Number Edit Box(1,4),
Text Box("Column Name"),
z2 = Text Edit Box("Optional"),
z2 << set width(100),
), // end 2nd column h list box
H List Box(
Text Box("Number of Characters"),
y3 = Number Edit Box(3,4),
Text Box("Column Name"),
z3 = Text Edit Box("Tube Type"),
z3 << set width(100),
), // end 3rd column h list box
H List Box(
Text Box("Number of Characters"),
y4 = Number Edit Box(3,4),
Text Box("Column Name"),
z4 = Text Edit Box("Sample Number"),
z4 << set width(100),
), // end 4th column h list box
H List Box(
Text Box("Number of Characters"),
y5 = Number Edit Box(1,4),
Text Box("Column Name"),
z5 = Text Edit Box("Analyte Level"),
z5 << set width(100),
), // end 5th column h list box
H List Box(
Text Box("Number of Characters"),
y6 = Number Edit Box(1,4),
Text Box("Column Name"),
z6 = Text Edit Box("Run"),
z6 << set width(100),
), // end 6th column h list box
), //end VLISTBOX
), // end sib append
value == 7,
Try( (this << sib) << deletebox ); // delete what might already exist
this << sibappend( // add new box
V List Box(
H List Box(
Text Box("Number of Characters"),
y = Number Edit Box(2,4),
Text Box("Column Name"),
z = Text Edit Box("Protocol"),
z << set width(100),
), // end 1st column HLISTBOX
H List Box(
Text Box("Number of Characters"),
y2 = Number Edit Box(1,4),
Text Box("Column Name"),
z2 = Text Edit Box("Optional"),
z2 << set width(100),
), // end 2nd column h list box
H List Box(
Text Box("Number of Characters"),
y3 = Number Edit Box(3,4),
Text Box("Column Name"),
z3 = Text Edit Box("Tube Type"),
z3 << set width(100),
), // end 3rd column h list box
H List Box(
Text Box("Number of Characters"),
y4 = Number Edit Box(3,4),
Text Box("Column Name"),
z4 = Text Edit Box("Sample Number"),
z4 << set width(100),
), // end 4th column h list box
H List Box(
Text Box("Number of Characters"),
y5 = Number Edit Box(1,4),
Text Box("Column Name"),
z5 = Text Edit Box("Analyte Level"),
z5 << set width(100),
), // end 5th column h list box
H List Box(
Text Box("Number of Characters"),
y6 = Number Edit Box(1,4),
Text Box("Column Name"),
z6 = Text Edit Box("Run"),
z6 << set width(100),
), // end 6th column h list box
H List Box(
Text Box("Number of Characters"),
y7 = Number Edit Box(1,4),
Text Box("Column Name"),
z7 = Text Edit Box("extra"),
z7 << set width(100),
), // end 7th column h list box
), //end VLISTBOX
); // end sib append
); // end if statement
)) //end function
), //end combo box
V List Box(
H List Box(
Text Box("Number of Characters"),
y = Number Edit Box(2,4),
Text Box("Column Name"),
z = Text Edit Box("Protocol"),
z << set width(100),
) // end 1st column HLISTBOX
); // since 1 is selected by default, put the box here initially
), //end VLISTBOXDIGITS
), // end HLISTBOX Main Box
H List Box("OK and Cancel",
Button Box("OK",
Print( "Pressed OK");
SelectedColumn = colListData << getSelected;
firstdigit = y << get();
seconddigit = y2 << get();
thirddigit = y3 << get();
fourthdigit = y4 << get();
fifthdigit = y5 << get();
sixthdigit = y6 << get();
seventhdigit = y7 << get();
firstColumnName = z << getText();
secondColumnName = z2 << getText();
thirdColumnName = z3 << getText();
fourthColumnName = z4 << getText();
fifthColumnName = z5 << getText();
sixthColumnName = z6 << getText();
seventhColumnName = z7 << getText();
currentwindow() << closewindow()
), // end Button Box OK
Button Box("Cancel", currentwindow() << closewindow())
), // end Button Box Cancel
); //end SID parser dialog box
try( dt << Delete Column( ascolumn(firstColumnName)) );
dt << new column(firstColumnName, character, nominal,
Formula(substr(ascolumn(SelectedColumn),0,firstdigit),empty())
);
try( dt << Delete Column( ascolumn(secondColumnName)) );
dt << new column(secondColumnName, character, nominal,
Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,1),seconddigit),empty())
);
try( dt << Delete Column( ascolumn(thirdColumnName)) );
dt << new column(thirdColumnName, character, nominal,
Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,1),thirddigit),empty())
);
try( dt << Delete Column( ascolumn(fourthColumnName)) );
dt << new column(fourthColumnName, character, nominal,
Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,thirddigit,1),fourthdigit),empty())
);
try( dt << Delete Column( ascolumn(fifthColumnName)) );
dt << new column(fifthColumnName, character, nominal,
Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,thirddigit,fourthdigit,1),fifthdigit),empty())
);
try( dt << Delete Column( ascolumn(sixthColumnName)) );
dt << new column(sixthColumnName, character, nominal,
Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,thirddigit,fourthdigit,fifthdigit,1),sixthdigit),empty())
);
try( dt << Delete Column( ascolumn(seventhColumnName)) );
dt << new column(seventhColumnName, character, nominal,
Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,thirddigit,fourthdigit,fifthdigit,sixthdigit,1),seventhdigit),empty())