ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4UIcontrolMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4UIcontrolMessenger.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 
29 #include <stdlib.h>
30 #include "G4UIcontrolMessenger.hh"
31 #include "G4UImanager.hh"
32 #include "G4UIdirectory.hh"
33 #include "G4UIcommand.hh"
34 #include "G4UIparameter.hh"
35 #include "G4UIcmdWithAString.hh"
36 #include "G4UIcmdWithABool.hh"
37 #include "G4UIcmdWithAnInteger.hh"
39 #include "G4UIaliasList.hh"
40 #include "G4StateManager.hh"
41 #include "G4UIsession.hh"
42 #include "G4Tokenizer.hh"
43 
44 #include "G4ios.hh"
45 
47 {
48  controlDirectory = new G4UIdirectory("/control/");
49  controlDirectory->SetGuidance("UI control commands.");
50 
51  macroPathCommand = new G4UIcmdWithAString("/control/macroPath",this);
52  macroPathCommand->SetGuidance("Set macro search path"
53  " with colon-separated list.");
54  macroPathCommand->SetParameterName("path",false);
55 
56  ExecuteCommand = new G4UIcmdWithAString("/control/execute",this);
57  ExecuteCommand->SetGuidance("Execute a macro file.");
58  ExecuteCommand->SetParameterName("fileName",false);
60 
61  loopCommand = new G4UIcommand("/control/loop",this);
62  loopCommand->SetGuidance("Execute a macro file more than once.");
63  loopCommand->SetGuidance("Loop counter can be used as an aliased variable.");
64  G4UIparameter* param1 = new G4UIparameter("macroFile",'s',false);
65  loopCommand->SetParameter(param1);
66  G4UIparameter* param2 = new G4UIparameter("counterName",'s',false);
67  loopCommand->SetParameter(param2);
68  G4UIparameter* param3 = new G4UIparameter("initialValue",'d',false);
69  loopCommand->SetParameter(param3);
70  G4UIparameter* param4 = new G4UIparameter("finalValue",'d',false);
71  loopCommand->SetParameter(param4);
72  G4UIparameter* param5 = new G4UIparameter("stepSize",'d',true);
73  param5->SetDefaultValue(1.0);
74  loopCommand->SetParameter(param5);
76 
77  foreachCommand = new G4UIcommand("/control/foreach",this);
78  foreachCommand->SetGuidance("Execute a macro file more than once.");
79  foreachCommand->SetGuidance("Loop counter can be used as an aliased variable.");
80  foreachCommand->SetGuidance("Values must be separated by a space.");
81  G4UIparameter* param6 = new G4UIparameter("macroFile",'s',false);
83  G4UIparameter* param7 = new G4UIparameter("counterName",'s',false);
85  G4UIparameter* param8 = new G4UIparameter("valueList",'s',false);
88 
89  suppressAbortionCommand = new G4UIcmdWithAnInteger("/control/suppressAbortion",this);
90  suppressAbortionCommand->SetGuidance("Suppress the program abortion caused by G4Exception.");
91  suppressAbortionCommand->SetGuidance("Suppression level = 0 : no suppression");
92  suppressAbortionCommand->SetGuidance(" = 1 : suppress during EventProc state");
93  suppressAbortionCommand->SetGuidance(" = 2 : full suppression, i.e. no abortion by G4Exception");
94  suppressAbortionCommand->SetGuidance("When abortion is suppressed, you will get error messages issued by G4Exception,");
95  suppressAbortionCommand->SetGuidance("and there is NO guarantee for the correct result after the G4Exception error message.");
97  suppressAbortionCommand->SetRange("level >= 0 && level <= 2");
99 
100  verboseCommand = new G4UIcmdWithAnInteger("/control/verbose",this);
101  verboseCommand->SetGuidance("Applied command will also be shown on screen.");
102  verboseCommand->SetGuidance("This command is useful with MACRO file.");
103  verboseCommand->SetGuidance(" 0 : silent");
104  verboseCommand->SetGuidance(" 1 : only the valid commands are shown.");
105  verboseCommand->SetGuidance(" 2 : comment lines are also shown (default).");
106  verboseCommand->SetParameterName("switch",true);
107  verboseCommand->SetRange("switch >= 0 && switch <=2");
109 
110  doublePrecCommand = new G4UIcmdWithABool("/control/useDoublePrecision",this);
111  doublePrecCommand->SetGuidance("Use double precision for printing out the current parameter value(s).");
112  doublePrecCommand->SetParameterName("useDoublePrecision",true);
114 
115  historyCommand = new G4UIcmdWithAString("/control/saveHistory",this);
116  historyCommand->SetGuidance("Store command history to a file.");
117  historyCommand->SetGuidance("Defaul file name is G4history.macro.");
118  historyCommand->SetParameterName("fileName",true);
119  historyCommand->SetDefaultValue("G4History.macro");
120 
122  = new G4UIcmdWithoutParameter("/control/stopSavingHistory",this);
123  stopStoreHistoryCommand->SetGuidance("Stop saving history file.");
124 
125  aliasCommand = new G4UIcommand("/control/alias",this);
126  aliasCommand->SetGuidance("Set an alias.");
127  aliasCommand->SetGuidance("String can be aliased by this command.");
128  aliasCommand->SetGuidance("The string may contain one or more spaces,");
129  aliasCommand->SetGuidance("the string must be enclosed by double quotes (\").");
130  aliasCommand->SetGuidance("To use an alias, enclose the alias name with");
131  aliasCommand->SetGuidance("parenthesis \"{\" and \"}\".");
132  G4UIparameter* aliasNameParam = new G4UIparameter("aliasName",'s',false);
133  aliasCommand->SetParameter(aliasNameParam);
134  G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue",'s',false);
135  aliasCommand->SetParameter(aliasValueParam);
136 
137  unaliasCommand = new G4UIcmdWithAString("/control/unalias",this);
138  unaliasCommand->SetGuidance("Remove an alias.");
139  unaliasCommand->SetParameterName("aliasName",false);
140 
141  listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias",this);
142  listAliasCommand->SetGuidance("List aliases.");
143 
144  getEnvCmd = new G4UIcmdWithAString("/control/getEnv",this);
145  getEnvCmd->SetGuidance("Get a shell environment variable and define it as an alias.");
146 
147  getValCmd = new G4UIcommand("/control/getVal",this);
148  getValCmd->SetGuidance("Get the current value of the UI command and define it as an alias.");
149  getValCmd->SetGuidance("Command is ignored if the UI command does not support GetCurrentValue().");
150  getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command> <iIdx>");
151  G4UIparameter* aliName = new G4UIparameter("alias_name",'s',false);
152  getValCmd->SetParameter(aliName);
153  G4UIparameter* comName = new G4UIparameter("UI_command",'s',false);
154  getValCmd->SetParameter(comName);
155  G4UIparameter* iIdxParam = new G4UIparameter("iIdx",'i',true);
156  iIdxParam->SetDefaultValue(0);
157  getValCmd->SetParameter(iIdxParam);
158 
159  echoCmd = new G4UIcmdWithAString("/control/echo",this);
160  echoCmd->SetGuidance("Display the aliased value.");
161 
162  shellCommand = new G4UIcmdWithAString("/control/shell",this);
163  shellCommand->SetGuidance("Execute a (Unix) SHELL command.");
164 
165  ManualCommand = new G4UIcmdWithAString("/control/manual",this);
166  ManualCommand->SetGuidance("Display all of sub-directories and commands.");
167  ManualCommand->SetGuidance("Directory path should be given by FULL-PATH.");
168  ManualCommand->SetParameterName("dirPath",true);
171 
172  HTMLCommand = new G4UIcmdWithAString("/control/createHTML",this);
173  HTMLCommand->SetGuidance("Generate HTML files for all of sub-directories and commands.");
174  HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH.");
175  HTMLCommand->SetParameterName("dirPath",true);
178 
179  maxStoredHistCommand = new G4UIcmdWithAnInteger("/control/maximumStoredHistory",this);
180  maxStoredHistCommand->SetGuidance("Set maximum number of stored UI commands.");
183 
184  ifCommand = new G4UIcommand("/control/if",this);
185  ifCommand->SetGuidance("Execute a macro file if the expression is true.");
186  ifCommand->SetGuidance(" Syntax : <double> <comp> <double> <macro_file>");
187  G4UIparameter* leftParam = new G4UIparameter("left",'d',false);
188  ifCommand->SetParameter(leftParam);
189  G4UIparameter* compParam = new G4UIparameter("comp",'s',false);
190  compParam->SetParameterCandidates("> >= < <= == !=");
191  ifCommand->SetParameter(compParam);
192  G4UIparameter* rightParam = new G4UIparameter("right",'d',false);
193  ifCommand->SetParameter(rightParam);
194  G4UIparameter* macroFileParam = new G4UIparameter("macroFile",'s',false);
195  ifCommand->SetParameter(macroFileParam);
197 
198  doifCommand = new G4UIcommand("/control/doif",this);
199  doifCommand->SetGuidance("Execute a UI command if the expression is true.");
200  doifCommand->SetGuidance(" Syntax : <double> <comp> <double> <UI_command>");
201  G4UIparameter* doleftParam = new G4UIparameter("left",'d',false);
202  doifCommand->SetParameter(doleftParam);
203  G4UIparameter* docompParam = new G4UIparameter("comp",'s',false);
204  docompParam->SetParameterCandidates("> >= < <= == !=");
205  doifCommand->SetParameter(docompParam);
206  G4UIparameter* dorightParam = new G4UIparameter("right",'d',false);
207  doifCommand->SetParameter(dorightParam);
208  G4UIparameter* comParam = new G4UIparameter("UI_command",'s',false);
209  doifCommand->SetParameter(comParam);
211 
212  addCommand = new G4UIcommand("/control/add",this);
213  addCommand->SetGuidance("Define a new alias as the sum of two values.");
214  addCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
215  addCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
216  addCommand->SetGuidance(" aliased value is alternated.");
217  G4UIparameter* newAlias1 = new G4UIparameter("new_alias",'s',false);
218  addCommand->SetParameter(newAlias1);
219  G4UIparameter* val1a = new G4UIparameter("value1",'d',false);
220  addCommand->SetParameter(val1a);
221  G4UIparameter* val1b = new G4UIparameter("value2",'d',false);
222  addCommand->SetParameter(val1b);
224 
225  subtractCommand = new G4UIcommand("/control/subtract",this);
226  subtractCommand->SetGuidance("Define a new alias as the subtraction of two values.");
227  subtractCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
228  subtractCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
229  subtractCommand->SetGuidance(" aliased value is alternated.");
230  G4UIparameter* newAlias2 = new G4UIparameter("new_alias",'s',false);
231  subtractCommand->SetParameter(newAlias2);
232  G4UIparameter* val2a = new G4UIparameter("value1",'d',false);
234  G4UIparameter* val2b = new G4UIparameter("value2",'d',false);
237 
238  multiplyCommand = new G4UIcommand("/control/multiply",this);
239  multiplyCommand->SetGuidance("Define a new alias as the multiplication of two values.");
240  multiplyCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
241  multiplyCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
242  multiplyCommand->SetGuidance(" aliased value is alternated.");
243  G4UIparameter* newAlias3 = new G4UIparameter("new_alias",'s',false);
244  multiplyCommand->SetParameter(newAlias3);
245  G4UIparameter* val3a = new G4UIparameter("value1",'d',false);
247  G4UIparameter* val3b = new G4UIparameter("value2",'d',false);
250 
251  divideCommand = new G4UIcommand("/control/divide",this);
252  divideCommand->SetGuidance("Define a new alias as the division of two values.");
253  divideCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
254  divideCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
255  divideCommand->SetGuidance(" aliased value is alternated.");
256  G4UIparameter* newAlias4 = new G4UIparameter("new_alias",'s',false);
257  divideCommand->SetParameter(newAlias4);
258  G4UIparameter* val4a = new G4UIparameter("value1",'d',false);
259  divideCommand->SetParameter(val4a);
260  G4UIparameter* val4b = new G4UIparameter("value2",'d',false);
261  val4b->SetParameterRange("value2 != 0.");
262  divideCommand->SetParameter(val4b);
264 
265  remainderCommand = new G4UIcommand("/control/remainder",this);
266  remainderCommand->SetGuidance("Define a new alias as the remainder of two values.");
267  remainderCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
268  remainderCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
269  remainderCommand->SetGuidance(" aliased value is alternated.");
270  G4UIparameter* newAlias5 = new G4UIparameter("new_alias",'s',false);
271  remainderCommand->SetParameter(newAlias5);
272  G4UIparameter* val5a = new G4UIparameter("value1",'i',false);
274  G4UIparameter* val5b = new G4UIparameter("value2",'i',false);
275  val4b->SetParameterRange("value2 != 0");
278 
279  strifCommand = new G4UIcommand("/control/strif",this);
280  strifCommand->SetGuidance("Execute a macro file if the expression is true.");
281  strifCommand->SetGuidance(" Syntax : <string> <comp> <string> <macro_file>");
282  G4UIparameter* strleftParam = new G4UIparameter("left",'s',false);
283  strifCommand->SetParameter(strleftParam);
284  G4UIparameter* strcompParam = new G4UIparameter("comp",'s',false);
285  strcompParam->SetParameterCandidates("== !=");
286  strifCommand->SetParameter(strcompParam);
287  G4UIparameter* strrightParam = new G4UIparameter("right",'s',false);
288  strifCommand->SetParameter(strrightParam);
289  G4UIparameter* strmacroFileParam = new G4UIparameter("macroFile",'s',false);
290  strifCommand->SetParameter(strmacroFileParam);
292 
293  strdoifCommand = new G4UIcommand("/control/strdoif",this);
294  strdoifCommand->SetGuidance("Execute a UI command if the expression is true.");
295  strdoifCommand->SetGuidance(" Syntax : <string> <comp> <string> <UI_command>");
296  G4UIparameter* strdoleftParam = new G4UIparameter("left",'s',false);
297  strdoifCommand->SetParameter(strdoleftParam);
298  G4UIparameter* strdocompParam = new G4UIparameter("comp",'s',false);
299  strdocompParam->SetParameterCandidates("== !=");
300  strdoifCommand->SetParameter(strdocompParam);
301  G4UIparameter* strdorightParam = new G4UIparameter("right",'s',false);
302  strdoifCommand->SetParameter(strdorightParam);
303  G4UIparameter* strdomacroFileParam = new G4UIparameter("UI_command",'s',false);
304  strdoifCommand->SetParameter(strdomacroFileParam);
306 
307  ifBatchCommand = new G4UIcmdWithAString("/control/ifBatch",this);
308  ifBatchCommand->SetGuidance("Execute a macro file if program is running in batch mode.");
309  ifBatchCommand->SetParameterName("macroFile",false);
311 
312  ifInteractiveCommand = new G4UIcmdWithAString("/control/ifInteractive",this);
313  ifInteractiveCommand->SetGuidance("Execute a macro file if program is running in interactive mode.");
314  ifInteractiveCommand->SetParameterName("macroFile",false);
316 
317  doifBatchCommand = new G4UIcmdWithAString("/control/doifBatch",this);
318  doifBatchCommand->SetGuidance("Execute a UI command if program is running in batch mode.");
319  doifBatchCommand->SetParameterName("UIcommand",false);
321 
322  doifInteractiveCommand = new G4UIcmdWithAString("/control/doifInteractive",this);
323  doifInteractiveCommand->SetGuidance("Execute a UI command if program is running in interactive mode.");
324  doifInteractiveCommand->SetParameterName("UIcommand",false);
326 
327 }
328 
330 {
331  delete macroPathCommand;
332  delete ExecuteCommand;
334  delete verboseCommand;
335  delete doublePrecCommand;
336  delete historyCommand;
338  delete ManualCommand;
339  delete aliasCommand;
340  delete unaliasCommand;
341  delete listAliasCommand;
342  delete getEnvCmd;
343  delete getValCmd;
344  delete echoCmd;
345  delete shellCommand;
346  delete loopCommand;
347  delete foreachCommand;
348  delete HTMLCommand;
349  delete maxStoredHistCommand;
350  delete ifCommand;
351  delete doifCommand;
352  delete addCommand;
353  delete subtractCommand;
354  delete multiplyCommand;
355  delete divideCommand;
356  delete remainderCommand;
357  delete strifCommand;
358  delete strdoifCommand;
359  delete ifBatchCommand;
360  delete ifInteractiveCommand;
361  delete doifBatchCommand;
362  delete doifInteractiveCommand;
363 
364  delete controlDirectory;
365 }
366 
368 {
370 
371  if( command == macroPathCommand) {
372  UI-> SetMacroSearchPath(newValue);
373  UI-> ParseMacroSearchPath();
374  }
375  if(command==ExecuteCommand)
376  {
377  command->ResetFailure();
378  UI-> ExecuteMacroFile(UI-> FindMacroPath(newValue));
379  if(UI->GetLastReturnCode() != 0)
380  {
382  ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
383  command->CommandFailed(UI->GetLastReturnCode(),ed);
384  }
385  }
386  if(command==suppressAbortionCommand)
387  {
389  }
390  if(command==verboseCommand)
391  {
393  }
394  if(command==doublePrecCommand)
395  {
397  }
398  if(command==historyCommand)
399  {
400  UI->StoreHistory(newValue);
401  }
402  if(command==stopStoreHistoryCommand)
403  {
404  UI->StoreHistory(false);
405  }
406  if(command==ManualCommand)
407  {
408  UI->ListCommands(newValue);
409  }
410  if(command==aliasCommand)
411  {
412  UI->SetAlias(newValue);
413  }
414  if(command==unaliasCommand)
415  {
416  UI->RemoveAlias(newValue);
417  }
418  if(command==listAliasCommand)
419  {
420  UI->ListAlias();
421  }
422  if(command==getEnvCmd)
423  {
424  command->ResetFailure();
425  if(std::getenv(newValue))
426  {
427  G4String st = newValue;
428  st += " ";
429  st += std::getenv(newValue);
430  UI->SetAlias(st.c_str());
431  }
432  else
433  {
435  ed << "<" << newValue << "> is not defined as a shell variable. Command ignored.";
436  command->CommandFailed(ed);
437  }
438  }
439  if(command==getValCmd)
440  {
441  G4Tokenizer next(newValue);
442  G4String aliName = next();
443  G4String com = next();
444  G4String curVal = UI->GetCurrentValues(com);
445  if(!(curVal.isNull()))
446  {
447  G4String theValue = curVal;
448  G4String iIdx = next();
449  if(!(iIdx.isNull()))
450  {
451  G4int idx = StoI(iIdx);
452  G4Tokenizer nextVal(curVal);
453  for(G4int i = 0;i<=idx;i++)
454  { theValue = nextVal(); }
455  }
456  G4String st = "/control/alias ";
457  st += aliName + " " + theValue;
458  UI->ApplyCommand(st);
459  }
460  }
461  if(command==echoCmd)
462  { G4cout << UI->SolveAlias(newValue) << G4endl; }
463  if(command==shellCommand)
464  {
465  command->ResetFailure();
466  int rc = system(newValue);
467  if ( rc < 0 )
468  {
470  ed << "<" << newValue << "> is not a valid shell command. Command ignored.";
471  command->CommandFailed(ed);
472  }
473  }
474  if(command==loopCommand)
475  {
476  command->ResetFailure();
477  UI->LoopS(newValue);
478  if(UI->GetLastReturnCode() != 0)
479  {
481  ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
482  command->CommandFailed(UI->GetLastReturnCode(),ed);
483  }
484  }
485  if(command==foreachCommand)
486  {
487  command->ResetFailure();
488  UI->ForeachS(newValue);
489  if(UI->GetLastReturnCode() != 0)
490  {
492  ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
493  command->CommandFailed(UI->GetLastReturnCode(),ed);
494  }
495  }
496  if(command==HTMLCommand)
497  {
498  UI->CreateHTML(newValue);
499  }
500  if(command==maxStoredHistCommand)
501  {
503  }
504  if(command==ifCommand)
505  {
506  G4Tokenizer next(newValue);
507  G4double l = StoD(next());
508  G4String comp = next();
509  G4double r = StoD(next());
510  G4String mac = next();
511  G4bool x = false;
512  if(comp==">") x = (l>r);
513  else if(comp==">=") x = (l>=r);
514  else if(comp=="<") x = (l<r);
515  else if(comp=="<=") x = (l<=r);
516  else if(comp=="==") x = (l==r);
517  else if(comp=="!=") x = (l!=r);
518  if(x) UI->ExecuteMacroFile(mac);
519  }
520  if(command==doifCommand)
521  {
522  G4Tokenizer next(newValue);
523  G4double l = StoD(next());
524  G4String comp = next();
525  G4double r = StoD(next());
526 
527  G4String c1 = next();
528  G4String ca;
529  while(!((ca=next()).isNull()))
530  {
531  c1 += " ";
532  c1 += ca;
533  }
534  if(c1(0)=='"')
535  {
536  G4String strippedValue;
537  if(c1(c1.length()-1)=='"')
538  { strippedValue = c1(1,c1.length()-2); }
539  else
540  { strippedValue = c1(1,c1.length()-1); }
541  c1 = strippedValue;
542  }
543 
544  G4bool x = false;
545  if(comp==">") x = (l>r);
546  else if(comp==">=") x = (l>=r);
547  else if(comp=="<") x = (l<r);
548  else if(comp=="<=") x = (l<=r);
549  else if(comp=="==") x = (l==r);
550  else if(comp=="!=") x = (l!=r);
551  if(x) UI->ApplyCommand(c1);
552  }
553  if(command==addCommand)
554  {
555  G4Tokenizer next(newValue);
556  G4String newA = next();
557  G4double l = StoD(next());
558  G4double r = StoD(next());
559  G4String st = "/control/alias ";
560  st += newA;
561  st += " ";
562  st += DtoS(l+r);
563  UI->ApplyCommand(st);
564  }
565  if(command==subtractCommand)
566  {
567  G4Tokenizer next(newValue);
568  G4String newA = next();
569  G4double l = StoD(next());
570  G4double r = StoD(next());
571  G4String st = "/control/alias ";
572  st += newA;
573  st += " ";
574  st += DtoS(l-r);
575  UI->ApplyCommand(st);
576  }
577  if(command==multiplyCommand)
578  {
579  G4Tokenizer next(newValue);
580  G4String newA = next();
581  G4double l = StoD(next());
582  G4double r = StoD(next());
583  G4String st = "/control/alias ";
584  st += newA;
585  st += " ";
586  st += DtoS(l*r);
587  UI->ApplyCommand(st);
588  }
589  if(command==divideCommand)
590  {
591  G4Tokenizer next(newValue);
592  G4String newA = next();
593  G4double l = StoD(next());
594  G4double r = StoD(next());
595  G4String st = "/control/alias ";
596  st += newA;
597  st += " ";
598  st += DtoS(l/r);
599  UI->ApplyCommand(st);
600  }
601  if(command==remainderCommand)
602  {
603  G4Tokenizer next(newValue);
604  G4String newA = next();
605  G4int l = StoI(next());
606  G4int r = StoI(next());
607  G4String st = "/control/alias ";
608  st += newA;
609  st += " ";
610  st += DtoS(l%r);
611  UI->ApplyCommand(st);
612  }
613  if(command==strifCommand)
614  {
615  G4Tokenizer next(newValue);
616  G4String l = next();
617  G4String comp = next();
618  G4String r = next();
619  G4String mac = next();
620  G4bool x = false;
621  if(comp=="==") { x = (l==r); }
622  else if(comp=="!=") { x = (l!=r); }
623  if(x) UI->ExecuteMacroFile(mac);
624  }
625  if(command==strdoifCommand)
626  {
627  G4Tokenizer next(newValue);
628  G4String l = next();
629  G4String comp = next();
630  G4String r = next();
631 
632  G4String c1 = next();
633  G4String ca;
634  while(!((ca=next()).isNull()))
635  {
636  c1 += " ";
637  c1 += ca;
638  }
639  if(c1(0)=='"')
640  {
641  G4String strippedValue;
642  if(c1(c1.length()-1)=='"')
643  { strippedValue = c1(1,c1.length()-2); }
644  else
645  { strippedValue = c1(1,c1.length()-1); }
646  c1 = strippedValue;
647  }
648 
649  G4bool x = false;
650  if(comp=="==") { x = (l==r); }
651  else if(comp=="!=") { x = (l!=r); }
652  if(x) UI->ApplyCommand(c1);
653  }
654  if(command==ifBatchCommand)
655  {
656  if(G4UIsession::InSession()==0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
657  }
658  if(command==ifInteractiveCommand)
659  {
660  if(G4UIsession::InSession()>0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
661  }
662  if(command==doifBatchCommand)
663  {
664  if(G4UIsession::InSession()==0) UI->ApplyCommand(newValue);
665  }
666  if(command==doifInteractiveCommand)
667  {
668  if(G4UIsession::InSession()>0) UI->ApplyCommand(newValue);
669  }
670 }
671 
673 {
675  G4String currentValue;
676 
677  if( command == macroPathCommand ) {
678  currentValue = UI-> GetMacroSearchPath();
679  }
680  if(command==verboseCommand)
681  {
682  currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel());
683  }
684  if(command==doublePrecCommand)
685  {
687  }
688  if(command==suppressAbortionCommand)
689  {
690  currentValue = suppressAbortionCommand->ConvertToString(G4StateManager::GetStateManager()->GetSuppressAbortion());
691  }
692  if(command==maxStoredHistCommand)
693  {
694  currentValue = maxStoredHistCommand->ConvertToString(UI->GetMaxHistSize());
695  }
696 
697  return currentValue;
698 }
699 
700