cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-48872%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EUso%20de%20cuadros%20deslizantes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-48872%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CDIV%20class%3D%22lia-message-template-problem-zone%22%3E%0A%3CH2%20id%3D%22toc-hId--1330329041%22%20id%3D%22toc-hId-1618847776%22%20id%3D%22toc-hId-1618847776%22%3EProblema%3C%2FH2%3E%0A%3CP%3EDesea%20utilizar%20un%20cuadro%20deslizante%20para%20establecer%20un%20valor%20continuo%20y%20desea%20ver%20el%20valor%20actual%20a%20medida%20que%20mueve%20el%20control%20deslizante.%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CDIV%20class%3D%22lia-message-template-diagnosis-zone%22%3E%0A%3CH2%20id%3D%22toc-hId--442825360%22%20id%3D%22toc-hId--933309185%22%20id%3D%22toc-hId--933309185%22%3ESoluci%C3%B3n%3C%2FH2%3E%0A%3CP%3ECree%20un%20cuadro%20deslizante%20y%20un%20cuadro%20de%20edici%C3%B3n%20de%20n%C3%BAmeros.%20Agregue%20un%20script%20al%20cuadro%20deslizante%20para%20actualizar%20el%20cuadro%20de%20edici%C3%B3n%20de%20n%C3%BAmeros.%20Agregue%20un%20script%20al%20cuadro%20de%20edici%C3%B3n%20de%20n%C3%BAmeros%20para%20actualizar%20el%20cuadro%20deslizante.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EEggs%20%3D%2050%3B%0ABacon%20%3D%2050%3B%0ANew%20Window(%20%22Slider%20Display%22%2C%0A%20%20%20%20Border%20Box(%20Left(%2010%20)%2C%20Right(%2010%20)%2C%20top(%2010%20)%2C%20bottom(%2010%20)%2C%0A%20%20%20%20%20%20%20%20V%20List%20Box(%0A%20%20%20%20%20%20%20%20%20%20%20%20H%20List%20Box(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Text%20Box(%20%22Eggs%22%20)%2C%20%2F%2F%20slider%20label%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20eggssb%20%3D%20Slider%20Box(%200%2C%20100%2C%20Eggs%2C%20%2F%2F%20slider%20script%20follows...%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20eggsnb%20%26lt%3B%26lt%3B%20set(%20Eggs%20)%3B%20%2F%2F%20update%20the%20value%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20this%20example%20doesn't%20need%20any%20other%20interactive%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20update.%20You%20could%20do%20some%20other%20work%20here%2C%20using%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20the%20slider's%20value%20to%20change%20a%20graph%2C%20perhaps.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20text%20box%20to%20hold%20the%20slider's%20value...%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20eggsnb%20%3D%20Number%20Edit%20Box(%20Eggs%2C%20%26lt%3B%3CSETFUNCTION%3E%3C%2FSETFUNCTION%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CDIV%20class%3D%22lia-message-template-solution-zone%22%3E%0A%3CH2%20id%3D%22toc-hId-444678321%22%20id%3D%22toc-hId-809501150%22%20id%3D%22toc-hId-809501150%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Window%20with%20Slider%20and%20Edit%20boxes%20launches%202nd%20window%22%20style%3D%22width%3A%20374px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Window%20with%20Slider%20and%20Edit%20boxes%20launches%202nd%20window%22%20style%3D%22width%3A%20374px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Window%20with%20Slider%20and%20Edit%20boxes%20launches%202nd%20window%22%20style%3D%22width%3A%20374px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F8759iF5CC6CDEE0E59C75%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Capture.PNG%22%20alt%3D%22Window%20with%20Slider%20and%20Edit%20boxes%20launches%202nd%20window%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EWindow%20with%20Slider%20and%20Edit%20boxes%20launches%202nd%20window%3C%2Fspan%3E%3C%2Fspan%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EWindow%20with%20Slider%20and%20Edit%20boxes%20launches%202nd%20window%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ELa%20ventana%20con%20control%20deslizante%20y%20cuadros%20de%20edici%C3%B3n%20abre%20la%20segunda%20ventana%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1332182002%22%20id%3D%22toc-hId--1742655811%22%20id%3D%22toc-hId--1742655811%22%3EDiscusi%C3%B3n%3C%2FH2%3E%0A%3CP%3ESlider%20Box%20y%20Number%20Edit%20Box%20tienen%20diferentes%20comportamientos.%20El%20cuadro%20deslizante%20mantiene%20la%20variable%20(Huevos%2C%20por%20ejemplo)%20y%20actualiza%20esa%20variable%20cuando%20se%20mueve%20el%20control%20deslizante.%20El%20script%20de%20devoluci%C3%B3n%20de%20llamada%20del%20control%20deslizante%20puede%20usar%20la%20variable%20directamente.%20El%20cuadro%20de%20edici%C3%B3n%20de%20n%C3%BAmeros%20no%20conserva%20la%20variable%20y%20no%20la%20actualiza.%20La%20funci%C3%B3n%20de%20devoluci%C3%B3n%20de%20llamada%20para%20la%20edici%C3%B3n%20del%20n%C3%BAmero%20de%20huevos%20utiliza%20%26lt%3B%3CGET%20para%3D%22%22%20obtener%3D%22%22%20el%3D%22%22%20valor%3D%22%22%20actual%3D%22%22%20y%3D%22%22%20almacenarlo%3D%22%22%20en%3D%22%22%20los%3D%22%22%20huevos.%3D%22%22%20pero%3D%22%22%20luego%3D%22%22%20solo%3D%22%22%20necesita%3D%22%22%20empujar%3D%22%22%20el%3D%22%22%20control%3D%22%22%20deslizante%3D%22%22%20con%3D%22%22%3E%26lt%3B%3CINVAL%20para%3D%22%22%20decirle%3D%22%22%20al%3D%22%22%20control%3D%22%22%20deslizante%3D%22%22%20que%3D%22%22%20vuelva%3D%22%22%20a%3D%22%22%20pintar%3D%22%22%20la%3D%22%22%20pantalla.%3D%22%22%20el%3D%22%22%20control%3D%22%22%20deslizante%3D%22%22%20obtendr%C3%A1%3D%22%22%20el%3D%22%22%20valor%3D%22%22%20para%3D%22%22%20volver%3D%22%22%20a%3D%22%22%20pintar%3D%22%22%20de%3D%22%22%20la%3D%22%22%20variable%3D%22%22%20huevos.%3D%22%22%3E%3C%2FINVAL%3E%3C%2FGET%3E%3C%2FP%3E%0A%3CP%3EPodr%C3%ADas%20hacer%20una%20variaci%C3%B3n%20un%20poco%20m%C3%A1s%20simple%20usando%20TextBox%20en%20lugar%20de%20NumberEditBox%2C%20pero%20probablemente%20querr%C3%A1s%20ingresar%20un%20valor%20exacto%2C%20lo%20cual%20es%20dif%C3%ADcil%20con%20un%20control%20deslizante.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--2075281613%22%20id%3D%22toc-hId-154524%22%20id%3D%22toc-hId-154524%22%3EVer%20tambi%C3%A9n%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2FDisplay_Boxes.shtml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2FDisplay_Boxes.shtml%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EAyuda-%26gt%3BLibros-%26gt%3BReferencia%20de%20sintaxis%20JSL%3C%2FP%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-514032%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Uso%20de%20cuadros%20deslizantes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-514032%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPuede%20obtener%20un%20cuadro%20deslizante%20para%20dar%20un%20resultado%20entero%20redonde%C3%A1ndolo%20en%20el%20script%20del%20cuadro%20deslizante%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0AsliderValue%20%3D%20.6%3B%0ANew%20Window(%22Slider%22%2C%20v%20list%20box(%0A%20text%20box(%22Slider%20box%20with%20integer%20output.%22)%2C%0A%20slider%20box(%0A%20%200%2C%0A%20%2010%2C%0A%20%20sliderValue%2C%0A%20%20sliderValue%20%3D%20round(sliderValue)%3B%0A%20%20tb%20%26lt%3B%26lt%3B%20Set%20Text(%20char(%20sliderValue%20)%20)%0A%20)%2C%0A%20tb%20%3D%20text%20box(%22%22)%0A))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-52615%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Uso%20de%20cuadros%20deslizantes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-52615%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EGracias%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEso%20lo%20resolvi%C3%B3%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Acara_con_una_leve_sonrisa%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-52588%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Uso%20de%20cuadros%20deslizantes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-52588%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%C2%A1Gracias!%3C%2FP%3E%0A%3CP%3ENecesitas%20agregar%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Egb%26lt%3B%3CINVAL%3E%3C%2FINVAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Een%20las%20dos%20funciones%20de%20devoluci%C3%B3n%20de%20llamada%20(para%20los%20cuadros%20de%20edici%C3%B3n%20de%20n%C3%BAmero%20de%20huevos%20y%20tocino)%20para%20notificar%20a%20GraphBox%20que%20se%20vuelva%20a%20dibujar.%20%26lt%3B%3CINVAL%20significa%3D%22%22%3E%3CEM%3E%20invalidar%3C%2FEM%3E%20y%20desencadena%20un%20redibujado.%20De%20la%20forma%20en%20que%20ha%20escrito%20el%20cuadro%20del%20gr%C3%A1fico%2C%20recoger%C3%A1%20los%20datos%20modificados%20cuando%20se%20vuelva%20a%20dibujar.%3C%2FINVAL%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-52583%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Uso%20de%20cuadros%20deslizantes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-52583%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Ehola%20craig%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C2%A1Gracias%20por%20una%20gran%20publicaci%C3%B3n!%3C%2FP%3E%3CP%3EModifiqu%C3%A9%20ligeramente%20su%20secuencia%20de%20comandos%20para%20ilustrar%20un%20problema%20que%20tengo%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EEggs%20%3D%2050%3B%0ABacon%20%3D%2050%3B%0ANew%20Window(%20%22Slider%20Display%22%2C%0A%20Border%20Box(%20Left(%2010%20)%2C%20Right(%2010%20)%2C%20top(%2010%20)%2C%20bottom(%2010%20)%2C%0A%20%20V%20List%20Box(%0A%20%20%20H%20List%20Box(%0A%20%20%20%20Text%20Box(%20%22Eggs%22%20)%2C%20%2F%2F%20slider%20label%0A%20%20%20%20eggssb%20%3D%20Slider%20Box(%0A%20%20%20%20%200%2C%0A%20%20%20%20%20100%2C%0A%20%20%20%20%20Eggs%2C%0A%20%20%20%20%20gb%20%26lt%3B%26lt%3B%20Set%20Graphics%20Script(%20Marker(%20%7BBacon%2C%20Eggs%7D%20)%20)%3B%2F%2F%20slider%20script%20follows...%0A%20%20%20%20%20eggsnb%20%26lt%3B%26lt%3B%20set(%20Eggs%20)%3B%20%2F%2F%20update%20the%20value%0A%20%20%20%20%20%2F%2F%20this%20example%20doesn't%20need%20any%20other%20interactive%0A%20%20%20%20%20%2F%2F%20update.%20You%20could%20do%20some%20other%20work%20here%2C%20using%0A%20%20%20%20%20%2F%2F%20the%20slider's%20value%20to%20change%20a%20graph%2C%20perhaps.%0A%20%20%20%20)%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20text%20box%20to%20hold%20the%20slider's%20value...%0A%20%20%20%20eggsnb%20%3D%20Number%20Edit%20Box(%0A%20%20%20%20%20Eggs%2C%0A%20%20%20%20%20%26lt%3B%3CSETFUNCTION%3E%3C%2FSETFUNCTION%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EMi%20problema%20es%20que%20el%20gr%C3%A1fico%20no%20se%20actualiza%20cuando%20ingreso%20un%20n%C3%BAmero%20en%20el%20cuadro%20de%20edici%C3%B3n%20de%20n%C3%BAmeros.%20El%20control%20deslizante%20se%20mueve%20cuando%20presiono%20%22Enter%22%2C%20pero%20el%20gr%C3%A1fico%20no%20refleja%20el%20cambio.%20He%20intentado%20algunas%20cosas%2C%20pero%20no%20puedo%20encontrar%20la%20manera%20de%20solucionarlo.%3C%2FP%3E%3CP%3E%C2%BFEspero%20que%20puedas%20ayudar%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBR%3C%2FP%3E%3CP%3EJesper%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Using Slider Boxes

Problem

You want to use a Slider Box to set a continuous value, and you want to see the current value as you move the slider.

Solution

Make a Slider Box and a Number Edit Box. Add a script to the Slider Box to update the Number Edit Box. Add a script to the Number Edit Box to update the Slider Box.

Eggs = 50;
Bacon = 50;
New Window( "Slider Display",
    Border Box( Left( 10 ), Right( 10 ), top( 10 ), bottom( 10 ),
        V List Box(
            H List Box(
                Text Box( "Eggs" ), // slider label
                eggssb = Slider Box( 0, 100, Eggs, // slider script follows...
                    eggsnb << set( Eggs ); // update the value
                    // this example doesn't need any other interactive
                    // update. You could do some other work here, using
                    // the slider's value to change a graph, perhaps.
                ), 
                // text box to hold the slider's value...
                eggsnb = Number Edit Box( Eggs, <<setfunction(
                        Function( {this}, // if the text box value changes
                            Eggs = this << get; // get the value
                            eggssb << inval; // update the slider
                        )
                    )
                )
            ),
            H List Box(
                Text Box( "Bacon" ), // slider label
                baconsb = Slider Box( 0, 100, Bacon, // slider script follows...
                    baconnb << set( Bacon ); // update the value
                ), 
                // text box to hold the slider's value...
                baconnb = Number Edit Box( Bacon, <<setfunction(
                        Function( {this}, // if the text box value changes
                            Bacon = this << get; // get the value
                            baconsb << inval; // update the slider
                        )
                    )
                )
            ),
            Button Box( "Make Breakfast", // button script follows...
                New Window( "Breakfast", Text Box( "eggs: " || Char( eggs ) || " and bacon: " || Char( bacon ) ) )
            )
        )
    )
);

Window with Slider and Edit boxes launches 2nd windowWindow with Slider and Edit boxes launches 2nd window

Discussion

Slider Box and Number Edit Box have different behaviors. The Slider Box holds on to the variable (Eggs, for example) and updates that variable when the slider moves. The slider callback script can use the variable directly. The Number Edit Box does not hold on to the variable, and does not update it. The callback function for the Eggs Number Edit uses <<get to get the current value and store it into Eggs. But then it only needs to prod the slider with an <<inval to tell the slider to repaint the display. The slider will get the value to repaint from the Eggs variable.

You could make a slightly simpler variation using TextBox rather than NumberEditBox, but you'll probably want to enter an exact value, which is hard with a slider.

See Also

http://www.jmp.com/support/help/Display_Boxes.shtml

Help->Books->JSL Syntax Reference

Comments

Hi Craig

 

Thank you for ea great post!

I modified your script slightly to illustrate a problem I am having:

Eggs = 50;
Bacon = 50;
New Window( "Slider Display",
	Border Box( Left( 10 ), Right( 10 ), top( 10 ), bottom( 10 ),
		V List Box(
			H List Box(
				Text Box( "Eggs" ), // slider label
				eggssb = Slider Box(
					0,
					100,
					Eggs,
					gb << Set Graphics Script( Marker( {Bacon, Eggs} ) );// slider script follows...
					eggsnb << set( Eggs ); // update the value
					// this example doesn't need any other interactive
					// update. You could do some other work here, using
					// the slider's value to change a graph, perhaps.
				), 
                // text box to hold the slider's value...
				eggsnb = Number Edit Box(
					Eggs,
					<<setfunction(
						Function( {this}, // if the text box value changes
							Eggs = this << get; // get the value
							eggssb << inval; // update the slider
						)
					)
				)
			),
			H List Box(
				Text Box( "Bacon" ), // slider label
				baconsb = Slider Box(
					0,
					100,
					Bacon,
					gb << Set Graphics Script( Marker( {Bacon, Eggs} ) );
                 // slider script follows...
					baconnb << set( Bacon ); // update the value
				), 
                // text box to hold the slider's value...
				baconnb = Number Edit Box(
					Bacon,
					<<setfunction(
						Function( {this}, // if the text box value changes
							Bacon = this << get; // get the value
							baconsb << inval; // update the slider
						)
					)
				)
			),
			Button Box( "Make Breakfast", // button script follows...
				New Window( "Breakfast",
					Text Box( "eggs: " || Char( eggs ) || " and bacon: " || Char( bacon ) )
				)
			)
		)
	),
	gb = Graph Box(
		Framesize( 300, 300 ),
		XName( "Bacon" ),
		YName( "Eggs" ),
		X Scale( 0, 100 ),
		Y Scale( 0, 100 ),
		Marker( {Bacon, Eggs} )
	)
);

My problem is that the graph does not update when I enter a number in the Number Edit Box. The slider moves when I press "Enter", but the graph does not reflect the change. I have tried a few things, but cant figure out how to fix it.

I hope you can help?

 

BR

Jesper

Thanks!

You need to add 

gb<<inval; // update the graphbox

in the two callback functions (for eggs and bacon number edit boxes) to notify the GraphBox to redraw istself. <<Inval means invalidate and triggers a redraw. The way you've written the graph box, it will pick up the changed data when it redraws.

Thank you

 

That solved it :)

ih

You can get a Slider Box to give an integer output by rounding it in the Slider Box's script:

Names Default To Here( 1 );
sliderValue = .6;
New Window("Slider", v list box(
	text box("Slider box with integer output."),
	slider box(
		0,
		10,
		sliderValue,
		sliderValue = round(sliderValue);
		tb << Set Text( char( sliderValue ) )
	),
	tb = text box("")
));
JSL Cookbook

If you’re looking for a code snippet or design pattern that performs a common task for your JSL project, the JSL Cookbook is for you.

This knowledge base contains building blocks of JSL code that you can use to reduce the amount of coding you have to do yourself.

It's also a great place to learn from the experts how to use JSL in new ways, with best practices.