Interpreter commands and syntax

The interpreter can be accessed from scripts (text documents with commands, executed using the "Tools - Scripts" dialog box) and also by typing directly in the console at the bottom of the window. (This window might be hidden in simplified versions)

The interpreter understands a simplified java syntax, including mathematical operations. You have access to all the viewable HOM variables, and in addition, it is possible to invoke many functions that are not normally accessible, e.g. those requiring one or more parameters.

  1. 01234.567E89 is the format for numeric literal double-precision floating point values.
  2. true, false represent boolean literal values
  3. String literals can be entered with double quotation marks.
  4. +, -, /, *, ^ are the normal mathematical operators. Note that the exponent x^y can be replaced with pow(x,y)
  5. item.subitem accesses an object found within another item, for example, blood.arterial.O2 represents the arterial oxygen content.
  6. FullVariableName accesses a variable by its full name, for example ArterialO2Content
  7. Abbreviated names for variables may be used to represent the values, for example APO2
  8. Functions can be called on objects, and objects or values can be passed as parameters, for example blood.add( Pharmacy.dispenseDrug("Adrenaline",0.001,1) )
  9. Multiple commands can be placed in one line (e.g. for scripts) using a semicolon delimiter.
  10. Temporary variables can be created to hold values in calculations, for example extract = blood.ultraFilter(0.100)

Useful functions from the library

These are a few examples of useful functions you can call:
  1. message("Message text") sends a string to the console along with the current date and time.
  2. drink(volume) adds a volume of water to the stomach
  3. eat(volume) adds a volume of food to the stomach
  4. time is a variable returning the current time and date as a string
  5. setRunning(true/false) instructs the engine to stop or start calculating
  6. PhicApplication.markEvent("TEST") marks the current time in the margin of the scrolling graph panel with the given text.
  7. actions.drinkAcid(), or actions.potassiumBolus() etc. etc. do what you expect them to.
  8. HTMLMessagePane.showDialog("HTML_Resource_Filename") shows a message dialog with the given html file displayed.
  9. Variables.forName("VariableName") searches the variable list for a variable that matches the given name
  10. Container_Object.withdrawVol(volume) returns a container with the specified volume of fluid removed from the given container. The container object could be any item which holds fluids, e.g. ecf, icf, blood, kidney.urine etc.
  11. Container_Object_1.add(Container_object_2) transfers the whole contents of container_2 into container_1
  12. Container_Object.filterSolids() returns a container with just the fluid compartment of the specified container. The solids remain in the original container.
  13. Drug_Container_Object.getDrugBinding( "DRUG_PROPERTY_NAME") returns a value indicating the amount of binding of drugs to a particular receptor, as given in the file resouces/Pharmacy.txt
  14. PhicApplication.frame.doSetup("FrameSetup.txt", "Setup_Type_Name") reinitialises the environment with a new setup section from the file resources/FrameSetup.txt
  15. DrugParser.createSubstance("Water 0.010 + K 0.005") returns a container, whose contents reflect the string typed in the box. Permitted additions include the standard container variables (Na, K, Glu, Prot etc.), Fluid names as defined in the file resources/Fluids.txt, and drug names as defined in the file resources/Pharmacy.txt; each item being followed by a number indicating how much to add.
  16. Organ.completedCycles returns the internal count of how many cycles of calculation have been performed in this instance of HOM.
  17. afterSeconds(7.50, "message( \"hi\" )" ) causes the command in quotes to be executed once after the given number of body-time seconds have elapsed. Notice that characters can be escaped with backslash '\' to allow special characters inside strings. You can use this to create sequences of events.

For a full list of variables, subvariables and functions, refer to the JavaDoc source documentation (this is a large file weighing 7 MB!) here

Root objects

The implicit root objects that are searched include

Mathematical functions

The mathematical functions normally accessible in the java.lang.Math class are accessible directly

 exp
 log
 log10
 E = exp(1)
 PI
 sqrt

 sin
 cos
 tan

 sec
 cosec
 cot

 sinh
 cosh
 tanh

 sech
 cosech
 coth
 
 acos
 asin
 atan
 atan2(x,y)

 random
 min(x,y)
 max(x,y)
 nCr(x,y)
 
 floor
 ceil
 abs
 sgn 
 mod(x, base)
 frac
 
 ramp
 truncatedRamp
 factorial
 eulerGamma = 0.57721...
 pow(x,y) = x^y
 
Back