littledevil 0 Posted August 16, 2016 Report Share Posted August 16, 2016 (edited) i have a csv file with dept names in separate lines likMOVIESBEAUTYBOOKS i have a variable called list count which gets randomly generated with a value btwen 0 and 5. no based on this number i m trying to create a new list and repeat the dept above in different rows on the list . e.glistcount=3 %dept= [0]->dept [1]->MOVIES [2]->MOVIES listcount=4 [3]->BEAUTY [4]->BEAUTY [5]->BEAUTY and so on but it doesnt add the items to create the list as above ...instead it creates he list as %dept [0]->dept [1]->MOVIES [2]->BEAUTY [3]->BOOKS ui open file("file", #myfile) create table from file(#myfile, &mydb) set(#totalcategories, $table total rows(&mydb), "Global") set(#row, 0, "Global") clear list(%dept) add item to list(%dept, "dept", "Delete", "Global") set(#listpos, 1, "Global") loop while(#row < #totalcategories) { set(#dept, $table cell(&mydb, #row, 0), "Global") set(#listcount, $rand(1, 5), "Global") set(#totallist, $eval($add(#listpos, #listcount)), "Global") loop while(#listpos < #totallist) { set(#tmpdept, $next list item(%dept), "Global") set list position(%dept, #listpos) add item to list(%dept, #dept, "Delete", "Global") increment(#listpos) } increment(#row) } alert("done") stop script Edited August 16, 2016 by littledevil Quote Link to post Share on other sites
HelloInsomnia 1103 Posted August 16, 2016 Report Share Posted August 16, 2016 I am a bit lost on what you are trying to do, maybe you can break it down a bit more and add some sample data to explain a bit more? Anyways, I noticed you want to repeat something, and in your code you are removing duplicate items from the list. This may be part of your problem so I made a slight tweak to change that. I don't know if it will help - since I'm unclear what you are trying to do - but it may help: ui open file("file",#myfile) create table from file(#myfile,&mydb) set(#totalcategories,$table total rows(&mydb),"Global") set(#row,0,"Global") clear list(%dept) add item to list(%dept,"dept","Delete","Global") set(#listpos,1,"Global") loop while(#row < #totalcategories) { set(#dept,$table cell(&mydb,#row,0),"Global") set(#listcount,$rand(1,5),"Global") set(#totallist,$eval($add(#listpos,#listcount)),"Global") loop while(#listpos < #totallist) { set(#tmpdept,$next list item(%dept),"Global") set list position(%dept,#listpos) add item to list(%dept,#dept,"Don\'t Delete","Global") increment(#listpos) } increment(#row) } alert("done") stop script 1 Quote Link to post Share on other sites
littledevil 0 Posted August 19, 2016 Author Report Share Posted August 19, 2016 yes delete was the culprit ...thanx Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.