It’s World Statistics Day! To honor the theme of the day, the JMP User Community is having conversations about the importance of trust in statistics and data. And we want to hear from you! Tell us the steps you take to ensure that your data is trustworthy.
Choose Language Hide Translation Bar
Level V

Script Only Runs Once in a Loop



The below script loops through files in two lists to check which of them match. If they do, the 'tagger' function is used to manipulate the files. I created this code for a GUI in which to test its functionality I chose four files (two for lf and two for lg). The probem is that when the condition is evaluated to true, the 'tagger' script only runs for the first of the matching two files, instead of all four matching files. Was wondering if I was missing something?

commenceTaggingScript2 = Expr(
 For(p = 1, p <= n items(lf), p++,
	For(q = 1, q <= nitems(lg), q++,
		if (Left(lf[p], Length(lf[p]) - 4) ==  Left(lg[q], Length(lg[q]) - 8), print("Sliced Lf: " || Left(lf[p], Length(lf[p]) - 4)); print("Sliced lg: " || Left(lg[q], Length(lg[q]) - 8)); tagger(selectedDirlf || lf[p], selectedDirlg || lg[q]) , print("Not matching"));




Re: Script Only Runs Once in a Loop

Your code worked for me (tried JMP 13 and JMP 14) after adding the following test data:

tagger = function({a, b}, print("tagging", a, b));
lf = {"abc1234", "xyz"};
lg = {"abc12345678", "xyz12345678"};
selectedDirlf = "/LF/";
selectedDirlg = "/LG/";



That is, I saw tagger called 2 times out of the 4 comparisons:

"Sliced Lf: abc"
"Sliced lg: abc"
"Not matching"
"Not matching"
"Sliced Lf: xyz"
"Sliced lg: xyz"

Article Labels

    There are no labels assigned to this post.