According to http://geant4.slac.stanford.edu/SLACTutorial14/UserInterface2.pdf page 10, the SetRange function member of G4UIcommand implements comparison between variables. I can't figure out if I'm doing something wrong, or if this feature was removed or bugged. // My cmd setup: cmd = new G4UIcommand("/my/path/cmd", this); G4UIparameter* a = new G4UIparameter("a", 'i', false); cmd->SetParameter(a); G4UIparameter* b = new G4UIparameter("b", 'i', false); cmd->SetParameter(b); // Now, this behaves well cmd->SetRange("a>0 && b>0") // But this gives errors in the output of command cmd->SetRange("a>0 && b>0 && b>a") // Output for a=0 && b=0 // integer operand expected for a>0 && b>0 && b>a. // integer operand expected for a>0 && b>0 && b>a. // parameter out of range: a>0 && b>0 && b>a // command refused (399):"/my/path/cmd 0 0"
Hi, If "0" is a valid value for "a" or "b", you should define the range as "a>=0 && b>=0". Also, please note that "a>=0 && b>=0 && b>a" is equivalent to "a>=0 && b>a". Makoto
So sorry for my poor example. Let's try again testing only for "a>b": cmd = new G4UIcommand("/my/path/cmd", this); cmd->SetRange("a>b"); G4UIparameter* a = new G4UIparameter("a", 'i', false); cmd->SetParameter(a); G4UIparameter* b = new G4UIparameter("b", 'i', false); cmd->SetParameter(b); # this is supposed to fail # Command: /my/path/cmd 1 2 # Output integer operand expected for a>b. integer operand expected for a>b. parameter out of range: a>b command refused (399):"/my/path/cmd 1 2" # this should work # Command: /my/path/cmd 2 1 # Output integer operand expected for a>b. integer operand expected for a>b. parameter out of range: a>b command refused (399):"/my/path/cmd 2 1" It fails either way. Normally when a command fails due to parameter range only the message "parameter out of range..." is printed. But I'm also getting the additional message of "integer operand expected for a>b" These messages come from G4UIcommand::Eval2. I think it's because arg1.type = arg2.type = IDENTIFIER, which I don't think is supposed to happen. I couldn't figure out anything else.
Thanks for the clarification. Now I understand the issue and I will look into it. Kind regards, Makoto
The fix will be included in the coming release of version 10.5. Thanks once again for reporting this bug. Makoto