Hi This is a repost of a bug from the geant4 forum: http://hypernews.slac.stanford.edu/HyperNews/geant4/get/userinterface/109.html ========================================================== Hello I did a quick search on google and I did not find any postings about this so here it goes... After seeing Makoto's presentation early this month, I was please to see /control/loop and /control/foreach commands implemented. However I run the following example and I found some unwanted behaviour: LINE1: /control/foreach Runtest.mac materialUSR "G4_POLYETHYLENE TNT WetSand5ppc isoN14 Graphite" LINE2: /control/foreach Runtest.mac materialUSR "G4_POLYETHYLENE TNT WetSand5ppc isoN14 Graphite " <- NOTE: 'extra spc Notice the difference btw L1 and L2 is the space at the end of the listing. Notice Runtest.mac is defined as: /APIsetup/target/setTargetMat {materialUSR} REMARK: This command is handle by my own DetectorConstruction Messenger class. When I run L1, I get the following error when running the fifth element of my list (At this point I have four output files: polyEt.root tnt.root wsand5.root n14.root): parameter value is not listed in the candidate List. ***** Illegal parameter (0) </APIsetup/target/setTargetMat {materialUSR}> ***** Based on experience, I took a guess and I assumed there is a problem with the tokenizer implemented for the UI cmd "/control/foreach". Hence I added an extra space at the end of the listing. It partially solved the problem EXCEPT now I output 6 files instead of the expected 5. Output files: polyEt.root tnt.root wsand5.root n14.root graphite.root graphite_0001.root Adding the extra space makes the last item in the list run twice. It would be great to have it fix. i did not trace the source code and I am totally assuming it is not dependent on my platform: uname -a Linux [xxxxHIDDENxxxxxx] 3.11.10-100.fc18.x86_64 #1 SMP Mon Dec 2 20:28:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux Regards, Chris ================================================== Ok so I was able to figure out (sort of) the bug that exist in the /control/foreach command. Here you can see it in my simple example. Run the folloiwng lines: /control/alias CM "1" /control/foreach ./g4macros/kookoo.mac CM "p pi- mu-" The macro file kookoo.mac has the following line in it: /control/echo {CM} The output I get is: p pi- mu-" Here in the output you can see the last element has an extra character referring to the char >>"<<. This causes the command to crash when executing the last element in the list. Please fix this bug!!!! Otherwise the /control/foreach command is not that useful. Cheers!!!! C Mos
Hi, Thanks for reporting this issue. The fix will be included in the next patch release. Meanwhile, please use this foreach command without double-quotes. Makoto