The Comment class gives you access to comment cards in PRIMER. More...
The PRIMER JavaScript API provides many class constants, properties and methods. For Arup to
be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase
or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you
should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your
own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:
| Name | Description |
| Comment.MULTIPLE | The *COMMENT is associated with all cards in the next block of keywords. |
| Comment.SINGLE | The *COMMENT is associated with just the one immediately following keyword. |
| Name | Type | Description |
| anchor_mode | integer | Anchor mode. Can be Comment.SINGLE, Comment.MULTIPLE. |
| exists (read only) | logical | true if comment exists, false if referred to but not defined. |
| header | string | The header of the comment, or empty if the comment has no header. |
| include | integer | The Include file number that the comment is in. |
| model (read only) | integer | The Model number that the comment is in. |
| nlines | integer | Number of lines in the comment. |
| noecho | logical | true if _NOECHO option is set, false if not. |
Detailed DescriptionThe Comment class allows you to create, modify, edit and manipulate comment cards. See the documentation below for more details. |
Constructornew Comment(Model[Model], Header (optional)[string], Mode (optional)[constant])DescriptionCreate a new Comment object. |
Model that comment will be created in
Comment number
Anchor: single or multiple
ReturnsComment object Return typeComment |
Details of functionsAddLine(Line content[String or array of strings], Line number (optional)[Integer])DescriptionAdds a line, or an array of lines, to a comment object. |
String that will be added to a line
0: First line, 1: Second line, etc.
If array of lines has been passed in the first argument, the first line of the array will be inserted in the line number specified in second argument, the second line of the array will be inserted in the following line number, etc.
If that line already exists, that line and rest of them below will be shifted down.
If greater than number of existing lines, blank lines will be added.
If lower than 0, not valid argument.
If no argument, the line(s) will be appended at the end.
Returnsno return value |
ExampleTo add a new line in the second row of comment c: var str = c.AddLine("New line", 1);
|
Browse(modal (optional)[boolean])DescriptionStarts an edit panel in Browse mode. |
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
Returnsno return value |
ExampleTo Browse comment c: c.Browse();
|
ClearFlag(flag[Flag])DescriptionClears a flag on the comment. |
Flag to clear on the comment
ReturnsNo return value |
ExampleTo clear flag f for comment c: c.ClearFlag(f);
|
Copy(range (optional)[boolean])DescriptionCopies the comment. The target include of the copied comment can be set using Options.copy_target_include. |
If you want to keep the copied item in the range specified for the current include. Default value is false. To set current include, use Include.MakeCurrentLayer().
ReturnsComment object Return typeComment |
ExampleTo copy comment c into comment z: var z = c.Copy();
|
Create(Model[Model], modal (optional)[boolean]) [static]DescriptionStarts an interactive editing panel to create a comment |
Model that the comment will be created in.
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
ReturnsComment object (or null if not made). Return typeComment |
ExampleTo start creating a comment in model m: var c = Comment.Create(m);
|
DeleteLine(Line number[Integer])DescriptionDeletes a line of a comment. |
Line number to delete (starting at 0). The following lines will be shifted up.
Returnsno return value |
ExampleTo delete the line in the second row of comment c: var str = c.DeleteLine(1);
|
Edit(modal (optional)[boolean])DescriptionStarts an interactive editing panel. |
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
Returnsno return value |
ExampleTo Edit comment c: c.Edit();
|
Error(message[string], details (optional)[string])DescriptionAdds an error for comment. For more details on checking see the Check class. |
The error message to give
An optional detailed error message
ReturnsNo return value |
ExampleTo add an error message "My custom error" for comment c: c.Error("My custom error");
|
First(Model[Model]) [static]DescriptionReturns the first comment in the model. |
Model to get first comment in
ReturnsComment object (or null if there are no comments in the model). Return typeComment |
ExampleTo get the first comment in model m: var c = Comment.First(m);
|
FlagAll(Model[Model], flag[Flag]) [static]DescriptionFlags all of the comments in the model with a defined flag. |
Model that all comments will be flagged in
Flag to set on the comments
ReturnsNo return value |
ExampleTo flag all of the comments with flag f in model m: Comment.FlagAll(m, f);
|
Flagged(flag[Flag])DescriptionChecks if the comment is flagged or not. |
Flag to test on the comment
Returnstrue if flagged, false if not. Return typeBoolean |
ExampleTo check if comment c has flag f set on it: if (c.Flagged(f) ) do_something...
|
ForEach(Model[Model], func[function], extra (optional)[any]) [static]DescriptionCalls a function for each comment in the model. |
Model that all comments are in
Function to call for each comment
An optional extra object/array/string etc that will appended to arguments when calling the function
ReturnsNo return value |
GetAll(Model[Model], property (optional)[string]) [static]DescriptionReturns an array of Comment objects or properties for all of the comments in a model in PRIMER. If the optional property argument is not given then an array of Comment objects is returned. If the property argument is given, that property value for each comment is returned in the array instead of a Comment object |
Model to get comments from
Name for property to get for all comments in the model
ReturnsArray of Comment objects or properties Return typeArray |
GetFlagged(Model[Model], flag[Flag], property (optional)[string]) [static]DescriptionReturns an array of Comment objects for all of the flagged comments in a model in PRIMER If the optional property argument is not given then an array of Comment objects is returned. If the property argument is given, then that property value for each comment is returned in the array instead of a Comment object |
Model to get comments from
Flag set on the comments that you want to retrieve
Name for property to get for all flagged comments in the model
ReturnsArray of Comment objects or properties Return typeArray |
GetFromID(Model[Model], number[integer]) [static]DescriptionReturns the Comment object for a comment ID. |
Model to find the comment in
number of the comment you want the Comment object for
ReturnsComment object (or null if comment does not exist). Return typeComment |
ExampleTo get the Comment object for comment 100 in model m var c = Comment.GetFromID(m, 100);
|
GetLine(Line (optional)[integer])DescriptionExtracts the lines (the strings) from a comment object. |
Line number to be extracted. Default value: 0 (first line)
ReturnsString (or null if no lines in the comment and not argument passed) Return typeString |
ExampleTo extract the first line of comment c: var str = c.GetLine();
|
GetParameter(prop[string])DescriptionChecks if a Comment property is a parameter or not. Note that object properties that are parameters are normally returned as the integer or float parameter values as that is virtually always what the user would want. For this function to work the JavaScript interpreter must use the parameter name instead of the value. This can be done by setting the Options.property_parameter_names option to true before calling the function and then resetting it to false afterwards.. This behaviour can also temporarily be switched by using the Comment.ViewParameters() method and 'method chaining' (see the examples below). |
comment property to get parameter for
ReturnsParameter object if property is a parameter, null if not. Return typeParameter |
Keyword()DescriptionReturns the keyword for this comment (*COMMENT) and the header of the comment if there is one. Note that a carriage return is not added. See also Comment.KeywordCards() |
No arguments
Returnsstring containing the keyword. Return typeString |
ExampleTo get the keyword for comment c: var key = c.Keyword();
|
KeywordCards()DescriptionReturns the keyword cards for the comment. Note that a carriage return is not added. See also Comment.Keyword() |
No arguments
Returnsstring containing the cards. Return typeString |
ExampleTo get the cards for comment c: var cards = c.KeywordCards();
|
Last(Model[Model]) [static]DescriptionReturns the last comment in the model. |
Model to get last comment in
ReturnsComment object (or null if there are no comments in the model). Return typeComment |
ExampleTo get the last comment in model m: var c = Comment.Last(m);
|
ModifyLine(Line number[Integer], New line content[String])DescriptionModifies the content of a line in a comment. |
Line number to modify (starting at 0)
String that replaces the existing one in a line
Returnsno return value |
ExampleTo modify the line in the second row of comment c: var str = c.ModifyLine(1, "Modified line");
|
Next()DescriptionReturns the next comment in the model. |
No arguments
ReturnsComment object (or null if there are no more comments in the model). Return typeComment |
ExampleTo get the comment in model m after comment c: var c = c.Next();
|
Previous()DescriptionReturns the previous comment in the model. |
No arguments
ReturnsComment object (or null if there are no more comments in the model). Return typeComment |
ExampleTo get the comment in model m before comment c: var c = c.Previous();
|
Select(flag[Flag], prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean]) [static]DescriptionAllows the user to select comments using standard PRIMER object menus. |
Flag to use when selecting comments
Text to display as a prompt to the user
If the argument is a Model then only comments from that model can be selected. If the argument is a Flag then only comments that are flagged with limit can be selected (limit should be different to flag). If omitted, or null, any comments can be selected. from any model.
If selection is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the selection will be modal.
ReturnsNumber of comments selected or null if menu cancelled Return typeNumber |
SetFlag(flag[Flag])DescriptionSets a flag on the comment. |
Flag to set on the comment
ReturnsNo return value |
ExampleTo set flag f for comment c: c.SetFlag(f);
|
Total(Model[Model], exists (optional)[boolean]) [static]DescriptionReturns the total number of comments in the model. |
Model to get total for
true if only existing comments should be counted. If false or omitted referenced but undefined comments will also be included in the total.
Returnsnumber of comments Return typeNumber |
ExampleTo get the total number of comments in model m: var total = Comment.Total(m);
|
UnflagAll(Model[Model], flag[Flag]) [static]DescriptionUnsets a defined flag on all of the comments in the model. |
Model that the defined flag for all comments will be unset in
Flag to unset on the comments
ReturnsNo return value |
ExampleTo unset the flag f on all the comments in model m: Comment.UnflagAll(m, f);
|
No arguments
ReturnsComment object. Return typeComment |
ExampleTo check if Comment property c.example is a parameter by using the Comment.GetParameter() method: if (c.ViewParameters().GetParameter(c.example) ) do_something...
|
Warning(message[string], details (optional)[string])DescriptionAdds a warning for comment. For more details on checking see the Check class. |
The warning message to give
An optional detailed warning message
ReturnsNo return value |
ExampleTo add a warning message "My custom warning" for comment c: c.Warning("My custom warning");
|
Xrefs()DescriptionReturns the cross references for this comment. |
No arguments
ReturnsXrefs object. Return typeXrefs |
ExampleTo get the cross references for comment c: var xrefs = c.Xrefs();
|
toString()DescriptionCreates a string containing the comment data in keyword format. Note that this contains the keyword header and the keyword cards. See also Comment.Keyword() and Comment.KeywordCards(). |
No arguments
Returnsstring Return typeString |
ExampleTo get data for comment c in keyword format var s = c.toString();
|