Wie suche ich nach eindeutigen Werten in der Spalte und verwende sie im Eingabefenster?Ich habe eine Tabelle, die ungefähr so aussieht. Ich möchte die Spalte "Becherfarbe" nach eindeutigen Werten durchsuchen und dann ein Popup-Fenster haben, in dem der Benutzer einen entsprechenden Geschmack für jede eindeutige Becherfarbe eingeben kann. .
| Becherfarbe | Kalorien | Schmecken | Rangfolge | Prüfer |
| Blau | 140 | 4 | 2 | 1 |
| Grün | 80 | 7 | 1 | 4 |
| Gelb | 200 | 2 | 3 | 6 |
| lila | 130 | 3 | 6 | 4 |
| Blau | 140 | 3 | 5 | 2 |
| Blau | 140 | 4 | 4 | 3 |
| Gelb | 200 | 5 | 7 | 1 |
Sobald wir einen Geschmack für jede Tassenfarbe haben, möchte ich eine neue Spalte hinzufügen, die basierend auf den Eingaben, die wir vom Benutzer erhalten haben, gefüllt wird.
| Becherfarbe | Kalorien | Schmecken | Rangfolge | Prüfer | Geschmack |
| Blau | 140 | 4 | 2 | 1 | Kirsche |
| Grün | 80 | 7 | 1 | 4 | Himbeere |
| Gelb | 200 | 2 | 3 | 6 | Schokolade |
| lila | 130 | 3 | 6 | 4 | richtig minzig |
| Blau | 140 | 3 | 5 | 2 | Kirsche |
| Blau | 140 | 4 | 4 | 3 | Kirsche |
| Gelb | 200 | 5 | 7 | 1 | Schokolade |
Ich bin immer noch ziemlich neu bei JSL und habe die letzten Stunden damit verbracht, Foren zu durchsuchen und nach Anleitungen zu suchen, aber ich kann das anscheinend nicht zusammensetzen. Ein wenig Hilfe wäre sehr willkommen.
Betreff: Wie suche ich nach eindeutigen Werten in der Spalte und verwende sie im Eingabefenster?Die Verwendung eines modalen Fensters ist ein sehr einzigartiger Fenstertyp.Es gibt mehrere Regeln, die Sie befolgen müssen.Eines davon beinhaltet eine Schaltflächenbox mit dem Text "OK".Es hat eine spezielle Funktion in einem modalen Fenster.Sie können sie also verwenden, aber Sie müssen sie studieren und etwas mit ihnen üben.
Ich bevorzuge es, keine modalen Fenster zu verwenden, sondern die Elemente Functions() oder Expr() zu verwenden, um den Code zu kapseln und zu verhindern, dass er ausgeführt wird, bis das Skript anzeigt, dass er ausgeführt werden soll.Nachfolgend finden Sie ein einfaches Beispiel dafür.
Names Default To Here( 1 );
// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );
// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i <= N Items( colorList ), i++,
Insert Into( flavorList, "" )
);
// Create the display window
nw = New Window( "Select Flavors",
//<< Modal,
Text Box( "Enter in Flavors for each Color" ),
tb = Table Box(
String Col Box( "Colors", colorList ),
scb = String Col Edit Box( "Flavors", flavorList )
),
Button Box( "OK",
nw << close window;
// Create the flavor table and update it to
// the original table
dt2 = New Table( "combined",
New Column( "Cup Color", character, set values( colorList ) ),
New Column( "Flavors", character, set values( flavorList ) )
);
dt << Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
close( dt2, nosave );
runAdditionalCodePlease;
)
);
// Set the String Col Edit Box action
scb << Set Function( Function( {this, which}, flavorList[which] = scb << get( which ) ) );
runAdditionalCodePlease = Expr(
Dialog("This represents the kind of things that",
"you may want to run after the data entry.",
"By placing the code inside an Expr() or in",
"a Function(). The code will be run only",
"when executed within the code."
)
);Betreff: Wie suche ich nach eindeutigen Werten in der Spalte und verwende sie im Eingabefenster?Ich muss mein Skript tatsächlich auf die Benutzereingabe warten, bevor es fortfährt.
Ich habe im Skriptleitfaden gefunden, dass ich dies tun kann, indem ich die modale Nachricht verwende, und dachte, dass ich sie korrekt hinzugefügt habe, aber wenn ich das Skript ausführe, wird die Tabelle jetzt nicht aktualisiert – im Protokoll steht: „Name nicht aufgelöst: Schaltfläche im Zugriff oder Auswertung von 'Button' , Button( 1 ) /*###*/"
// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );
// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i <= N Items( colorList ), i++,
Insert Into( flavorList, "" )
);
// Create the display window
nw = New Window( "Select Flavors",
<< Modal,
Text Box( "Enter in Flavors for each Color" ),
tb = Table Box(
String Col Box( "Colors", colorList ),
scb = String Col Edit Box( "Flavors", flavorList )
),
Button Box( "OK",
nw << close window;
// Create the flavor table and update it to
// the original table
dt2 = New Table( "combined",
New Column( "Cup Color", character, set values( colorList ) ),
New Column( "Flavors", character, set values( flavorList ) )
);
dt << Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
close( dt2, nosave );
)
);
// Set the String Col Edit Box action
scb << Set Function( Function( {this, which}, flavorList[which] = scb << get( which ) ) );Betreff: Wie suche ich nach eindeutigen Werten in der Spalte und verwende sie im Eingabefenster?Perfekt danke!Betreff: Wie suche ich nach eindeutigen Werten in der Spalte und verwende sie im Eingabefenster?Willkommen in der Community.
Zuerst habe ich einen Vorschlag, wie Sie das Erlernen von JSL beschleunigen können.
Lesen Sie den Skriptleitfaden!!!!
Es ist erhältlich unter
Hilfe==>Bücher==>Scripting Guide
Unten ist ein Barebones-Skript, um das zu erreichen, was Sie angefordert haben.
Names Default To Here( 1 );
dt = New Table( "Untitled 2",
Add Rows( 7 ),
New Column( "Cup Color",
Character,
"Nominal",
Set Selected,
Set Values( {"blue", "green", "yellow", "purple", "blue", "blue", "yellow"} )
),
New Column( "Calories",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [140, 80, 200, 130, 140, 140, 200] )
),
New Column( "Taste",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [4, 7, 2, 3, 3, 4, 5] )
),
New Column( "Ranking",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [2, 1, 3, 6, 5, 4, 7] )
),
New Column( "Tester",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 4, 6, 4, 2, 3, 1] )
)
);
// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );
// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i <= N Items( colorList ), i++,
Insert Into( flavorList, "" )
);
// Create the display window
nw = New Window( "Select Flavors",
Text Box( "Enter in Flavors for each Color" ),
tb = Table Box(
String Col Box( "Colors", colorList ),
scb = String Col Edit Box( "Flavors", flavorList )
),
Button Box( "OK",
nw << close window;
// Create the flavor table and update it to
// the original table
dt2 = New Table( "combined",
New Column( "Cup Color", character, set values( colorList ) ),
New Column( "Flavors", character, set values( flavorList ) )
);
dt << Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
close( dt2, nosave );
)
);
// Set the String Col Edit Box action
scb << Set Function( Function( {this, which}, flavorList[which] = scb << get( which ) ) );