Problem 2068 - Semantics problem in G4UICommand
Summary: Semantics problem in G4UICommand
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: intercoms (show other problems)
Version: 10.4
Hardware: PC Linux
: P4 minor
Assignee: asai
URL:
Depends on:
Blocks:
 
Reported: 2018-07-07 18:19 CEST by lapsintra
Modified: 2018-10-25 21:13 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description lapsintra 2018-07-07 18:19:01 CEST
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"
Comment 1 asai 2018-07-08 10:32:14 CEST
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
Comment 2 lapsintra 2018-07-08 20:05:23 CEST
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.
Comment 3 asai 2018-07-09 06:49:19 CEST
Thanks for the clarification. Now I understand the issue and I will look into it.
Kind regards,
Makoto
Comment 4 asai 2018-10-25 21:13:01 CEST
The fix will be included in the coming release of version 10.5.
Thanks once again for reporting this bug.
Makoto