<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>StudioTips - Notation</title> <meta name="keywords" content="omnis studio, raining data, studiotips documentation" /> <link rel="stylesheet" type="text/css" href="http://www.studiotips.net/css/codedoc.css" /> </head> <body> <div id="container"> <p><a href = ../index.html > Tips </a> &nbsp &gt; &nbsp <a href = index.html > Notation </a> &nbsp &gt; &nbsp Notation</p> <a name="notation" /> <h2>Notation</h2> <p>Notation allows you to do some very powerful things in Omnis Studio. I admit to being a notation junkie. Once you get then hang of notation in Omnis Studio it actually gets to be very easy to figure out. Virtually anything you can do in Omnis Studio manually or using Omnis commands, you can do using notation. This section cover tips, tricks, and pitfalls with notation.</p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/warning.gif" alt="Warning" /><p>Omnis notation can be addictive. Be careful. :-)</p> </div> <a name="notationinspector" /> <h3>Notation Inspector</h3> <p>Using the <span class="nav">F4 Notation Inspector</span> in conjunction with the <span class="nav">F6 Property Manager</span> can help you out big time with learning/using/writing notation. It took me over year to figure this out ... had I known it, I could have saved a <em>lot</em> of time learning and writing notation in Omnis Studio.</p> <p>Click the <span class="nav">Run Demo</span> button in the <span class="nav">StudioTips Browser</span> window to learn how to use the <span class="nav">Notation Inspector</span> and <span class="nav">Property Manager</span> for writing notation. The demo gives you a step by step well commented walk through using <span class="nav">Notation Inspector</span> and <span class="nav">Property Manager</span> while writing notation. The demo adds a button and method to the demo window instance.</p> <p>This demo was a lot of work to put together... so be sure to try it out. :-)</p> <p>The <span class="nav">F4 Notation Inspector</span> and the <span class="nav">F6 Property Manager</span> ... an amazing team!</p> Thanks to engineering for setting this up so we can use them interactively while stepping through and writing code! <a name="notationerrors" /> <h3>Notation Errors</h3> <p>If you select a library in the <span class="nav">F2 Brower</span> and look at the <span class="nav">Prefs</span> tab in the <span class="nav">F6 Property Manager</span> you will see a <span class="code">$reportnotationerrors</span> property. If set to <span class="code">kTrue</span> Omnis Studio will halt code executing whenever there is an error in your notation. I recommend setting this property to <span class="code">kTrue</span>. It will help you catch a lot of code errors that you would otherwise miss.</p> <p>If you attempt to send a message to any class instance (call a public method), and the recipient method does not exist, Omnis Studio will halt method execution and open the IDE at the offending method call. Without <span class="code">$reportnotationerrors</span> set to <span class="code">kTrue</span> Omnis Studio will simply pass over the line of code in your method and continue execution.</p> <p>You will run into problems with <span class="code">$reportnotation</span> errors set to <span class="code">kTrue</span> if your code is structured such that optional messages are sent to a class or object instance and your code isn't concerned whether or not a recipient method exists.</p> <p>A situation where this might occur is if you use <span class="code">$sendall</span> to send a message to all of the field objects in a window.</p> <p class="code"><span class="omcomment">; Give all the window objects an opportunity to set their own</span><br /> <span class="omcomment">; properties for 'edit' mode by sending them a $setMode message.</span><br /> <span class="omcomment">; Only objects that have a $setMode method will receive the message.</span><br /> Do $cinst.$objs.$sendall($ref.$setMode('edit'))</p> <p>If none of the window objects have an <span class="code">$setMode</span> method, Omnis Studio will report a notation error. The solution to this problem is to add a <span class="code">$cando</span> test to the <span class="code">$sendall</span> conditions.</p> <p class="code"><span class="omcomment">; Add $cando test to avoid notation errors.</span><br /> <span class="omcomment">; The $setMode message will only be sent to objects that have a $setMode method.</span><br /> Do $cinst.$objs.$sendall($ref.$setMode('edit'),$ref.$setMode.$cando)</p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/tip.gif" alt="Tip" /><p>In Omnis Studio v4.2 an optional 3rd <span class="code">$sendall</span> parameter, <span class="code">bIgnoreUnrecognizedCustomAttribute=kFalse</span>, was added. Setting the 3rd parmeter to <span class="code">kTrue</span> overcomes the above notation error problem.</p> </div> <a name="addvariable" /> <h3>Add Variable</h3> <p>Variables are part of the <span class="code">$?vardefs</span> group.</p> <ul> <li>Class variables: <span class="code">$cvardefs</span></li> <li>Instance variables: <span class="code">$ivardefs</span></li> <li>Local Variables and parameters: <span class="code">$lvardefs</span></li> </ul> <p>You can find the variable groups using the <span class="nav">F4 Notation Inspector</span>.</p> <p>The syntax for adding a variable using notation is as follows:<br /> <p class="code">Do VarDefsGroupRef.$add('VarName',pkDataType,pkDataSubType,pkDataSubLen,pbIsParamater) Returns VarRef</p> </p> <p>You can check <span class="nav">F9 Catalog</span> > <span class="nav">Constants</span> > <span class="nav">Data type</span> and <span class="nav">Data subtypes</span> for the possible parameters.</p> <p>Not all data types have a data subtype or data sublength. (See the sample list below.)</p> <p>The <span class="code">pbIsParameter</span> variable is only applicable to the <span class="code">$lvardefs</span> group and is only needed if you want the variable to be a parameter. Sending <span class="code">kTrue</span> as <span class="code">pbIsParameter</span> will make the variable to be the next parameter for the method. To the best of my knowledge you cannot insert a parameter before an existing parameter, it can only be added to the end of the existing parameters. If you are notationally copying parameters, you first need to make a list of the <span class="code">$lvardefs</span> and sort the <span class="code">$lvardefs</span> group by the <span class="code">$parmno</span> property, then loop through the list of adding the local variables so that they will remain in the same order. Remember to include any extra comma(s) in the list of parameters when adding a parameter that doesn't have a data subtype or data sublength.</p> <p class="code">Set Reference LocalVarsGroupRef to $libs.LIBRARY.$classes.CLASS.$methods.METHOD.$lvardefs<br /> <br /> Do LocalVarsGroupRef.$add('pLineNum',kInteger,kLongInt,,kTrue) Returns VarRef<br /> Do LocalVarsGroupRef.$add('pIsInsert',kBoolean,,,kTrue) Returns VarRef</p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/warning.gif" alt="Warning" /><p>You can not have a method add a local variable or parameter to itself. The variable must be added from outside of the method. You can not add an instance variable to an instance of a class, the variable must be added before the class is instantiated. A work around for adding instance variables to an instance is to include a row variable (e.g. <span class="code">iVarsRow</span>) in the window class which you can then add dynamically add columns after the window has been instantiated.</p> </div><p>The following is a sample list of the variables and their subtypes.</p> <p class="code">$add('Col_Char',kCharacter,kSimplechar,100)<br /> $add('Col_NatChar',kCharacter,kNatchar,100)<br /> $add('Col_Longint',kInteger,kLongint)<br /> $add('Col_Shortint',kInteger,kShortint)<br /> $add('Col_Date',kDate,kDate2000)<br /> $add('Col_Bool',kBoolean)<br /> $add('Col_NumFloatdp',kNumber,kFloatdp)<br /> $add('Col_Fieldref',kFieldreference)<br /> $add('Col_Itemref',kItemref)<br /> $add('Col_Binary',kBinary)<br /> $add('Col_List',kList)<br /> $add('Col_Object',kObject)<br /> $add('Col_Picture',kPicture)<br /> $add('Col_Row',kRow)<br /> $add('Col_Sequence',kSequence)</p> <p>To add a datetime variable</p> <p class="code">$add('Col_DateTime',kDate,kDatetime,16)</p> Where the sublength of 16 is the 16th item in the <span class="code">$clib</span>'s <span class="code">#DFORMS</span> system table list. Typically, this list starts out with only eight datetime formats; but can be expanded to include up to 30 datetime formats. It allows for custom date time formats. <a name="clearinstancevariables" /> <h3>Clear instance variables</h3> <p>If you need to clear the instance variables for any instance you can use <span class="code">$sendall</span> to clear them.</p> <p><span class="code">Do $cinst.$ivars.$sendall($ref.$assign(''))</span></p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/warning.gif" alt="Warning" /><p>The above <span class="code">$sendall</span> will blow away your row and list definitions.</p> </div> <a name="copywindowobjectusingnotation" /> <h3>Copy Window Object using Notation</h3> <p>You can copy any object and all it's attributes using notation.</p> <ol> <li>Set a reference to the source object you want to copy.</li> <li>Add the same object type to the target, returning a reference to it.</li> <li>Step through the attributes group of the source object, setting the target object attributes to the same values.</li> </ol><p class="code"><span class="omcomment">; Open the target window</span><br /> Do $clib.$windows.wNotationCopyWindowObject2.$openonce() Returns rWin<br /> <br /> <span class="omcomment">; Set a reference to the object to copy.</span><br /> Set reference rSource to $cinst.$objs.Object 1<br /> <br /> <span class="omcomment">; Find out what the $add method parameters are</span><br /> Do rWin.$objs.$add.$desc() Returns #S1<br /> <span class="omcomment">; $add(type[,cComponentLibrary,cComponentControl],iTop,iLeft,iHeight,iWidth[,bInvisible=kFalse,bDisabled=kFalse])</span><br /> <br /> <span class="omcomment">; Add the object to the target window, returning a reference.</span><br /> Do rWin.$objs.$add(rSource.$objtype,rSource.$top,rSource.$height,rSource.$left,rSource.$width) Returns rTarget<br /> <br /> <span class="omcomment">; Make a list of the attributes group for this object</span><br /> Do rSource.$attributes.$makelist($ref.$name) Returns List<br /> <br /> <span class="omcomment">; Loop through the attributes group, assigning each to the next object</span><br /> For List.$line from 1 to List.$linecount step 1<br /> &nbsp;&nbsp;&nbsp;Do rTarget.[List.C1].$assign(rSource.[List.C1])<br /> End For</p> <p>Click the <span class="nav">Run Demo</span> button in the <span class="nav">StudioTips Browser</span> for a demo.</p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/warning.gif" alt="Warning" /><p>If the source object has any methods you will need to copy the methods to the target object.</p> </div> <a name="copyaclass" /> <h3>Copy a Class</h3> <p>Copying a class using notation is very easy.</p> <p class="code"><span class="omcomment">; Set a reference to the source class.</span><br /> Set reference rSourceClass to $clib.$objects.ClassName<br /> <br /> <span class="omcomment">; Add a new object class named "oFunctions2".</span><br /> Do $clib.$objects.$add('NewClassName') Returns rNewClass<br /> <br /> <span class="omcomment">; Copy the $classdata from the source class to the new class.</span><br /> Do rNewClass.$classdata.$assign(rSourceClass.$classdata)</p> <a name="doinherited" /> <h3>Do inherited</h3> <p>The notation alternative to <span class="code">Do inherited Returns FlagOK</span> is:</p> <p><span class="code">Do $cinst.$inherited.[$cmethod().$name]() Returns FlagOK</span></p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/warning.gif" alt="Warning" /><p>If the superclass method has parameters, you will need to create the parameters in the overridden subclass method and include the parameters inside the parenthesis. It is not necessary to create the parameters in the subclass method if you are using <span class="code">Do inherited</span> unless you need access to the parameters in your subclass method or which to see them as you step through the code.</p> </div> <a name="overloadingproperties" /> <h3>Overloading Properties</h3> <p>While developing StudioTips I ran into snag with the <span class="code">$destruct</span> method in my window. I was using a superclass <span class="code">$destruct</span> method to save the last closed size and location of the subwindow class.</p> <p>The method failed because the subclassed window's <span class="code">$top, $left, $height, $width</span> properties were inherited from the superclass. To make the code work I had to overload these attributes for each subwindow using notation.</p> <p>Class properties that can be inherited from a superclass have an <span class="code">$isinherited</span> property which you can assign using notation. You can override or inherit a class property by setting the <span class="code">$isinherited</span> property to <span class="code">kFalse</span> or <span class="code">kTrue</span> respectively.</p> <p>The following sample code shows the solution I used to override and then store the subclass window size and location.</p> <p class="code"><span class="omcomment">; $destruct method of the superclass window.</span><br /> <br /> <span class="omcomment">; Using the $cinst window location and size, $assign those values to the windows $class so that it will reopen</span><br /> <span class="omcomment">; the same size and location as the user closed it. First check and overload $isinherited if needed.</span><br /> <br /> Set reference rSubWinClass to $cinst.$class<br /> <br /> <span class="omcomment">; Is the $top property inherited? If so overload the window size/location attributes.</span><br /> If rSubWinClass.$top.$isinherited<br /> &nbsp;&nbsp;&nbsp;Do rSubWinClass.$top.$isinherited.$assign(kFalse)<br /> &nbsp;&nbsp;&nbsp;Do rSubWinClass.$left.$isinherited.$assign(kFalse)<br /> &nbsp;&nbsp;&nbsp;Do rSubWinClass.$height.$isinherited.$assign(kFalse)<br /> &nbsp;&nbsp;&nbsp;Do rSubWinClass.$width.$isinherited.$assign(kFalse)<br /> End If<br /> <br /> <span class="omcomment">; Update this window's class size/location attributes so it will reopen the same size/location</span><br /> Do rSubWinClass.$top.$assign($cinst.$top)<br /> Do rSubWinClass.$left.$assign($cinst.$left)<br /> Do rSubWinClass.$height.$assign($cinst.$height)<br /> Do rSubWinClass.$width.$assign($cinst.$width)<br /> <br /> Quit method kTrue</p> <a name="parentsofareference" /> <h3>Parents of a Reference</h3> <p>You have a valid reference to an object, now you want to find out what library it is in, what class it is in, etc. (Anything in the <span class="code">$fullname</span> notation string of the item.</p> <p>To find this information, you add the name of the parent after the reference, then (), then <span class="code">$name</span> or any valid attribute.</p> <p>Example:</p> <p class="code"><span class="omcomment">; Set a reference to the first object in the tips browser window.</span><br /> Do $libs.tipsBase.$windows.wTipsBrowser.$objs.$first() Returns rField<br /> <br /> <span class="omcomment">; The field's name.</span><br /> Do rField().$name<br /> <br /> <span class="omcomment">; The name of the field's containing class.</span><br /> Do rField.$class().$name<br /> <br /> <span class="omcomment">; The name of the field's containing library.</span><br /> Do rField.$lib().$name</p> <a name="sendmessagetoallobjects" /> <h3>Send Message to All Objects</h3> <p>You can use $sendall to send a message to all to objects in a window.</p> <p>In the process of doing the demo windows for StudioTips I tripped across an interesting idea.</p> <p>In the "Lists - $merge" demo I had 3 lists, each with their own $construct which created their own lists. After doing each merge demo I wanted to reset all the lists to their original state.</p> <p>Behind the Reset button I added a single line of code:<br /> Do $cinst.$objs.$sendall($ref.$construct())</p> <p>It worked like a charm! You can check it out by clicking the Run Demo button.</p> Think about it, you could have a special method in all your window objects and with a single $sendall each object with that method could do something or return something. You could control the action take at the object level. There's some interesting possibilities... <a name="settingreferences" /> <h3>Setting References</h3> <p>Setting a reference to a class, class instance, method, or object is fairly easy to do. You create an item reference variable and then use the <span class="code">Set Reference</span> command or use <span class="code">$findname</span> to point the item reference variable to the the class, instance, method, or object.</p> <p class="code"><span class="omcomment">; Set reference the field in its $construct method.</span><br /> Set reference irWin to $cfield<br /> <br /> <span class="omcomment">; Set reference using $findname.</span><br /> Do $clib.$windows.$findname('wWinName') Returns irWin</p> <p>Setting a reference to a <em>variable</em> can be done using a setter method which receives the variable through a field reference parameter and then sets an item reference variable to point to the passed in <em>variable</em>.</p> <p class="code"><span class="omcomment">; Method: $setListRef ;; Set a reference to a list variable passed in by the parameter.</span><br /> <span class="omcomment">; Parameter: pfList - field reference variable.</span><br /> <span class="omcomment">; Instance Variable: irList - item reference variable.</span><br /> <br /> <span class="omcomment">; Set a reference to the list variable.</span><br /> Set reference irList to pfList.$ref<br /> Quit method kTrue</p> <p>Returning a reference to a <em>variable</em> can be done using a method which returns a reference to the <em>variable</em>.</p> <p class="code"><span class="omcomment">; Method: $retListRef - Return a reference to a list variable.</span><br /> <br /> <span class="omcomment">; Return a reference to the list variable.</span><br /> <span class="omcomment">; $ref.$ref is needed to return a reference instead of the whole list</span><br /> Quit method iList.$ref.$ref</p> <p>You can also use a getter method which passes a reference to the <em>variable</em> via a field reference parameter.</p> <p class="code"><span class="omcomment">; Method: $getListRef - Pass a reference to a list variable via the field reference parameter.</span><br /> <span class="omcomment">; Parameter: pfList - field reference variable.</span><br /> <br /> <span class="omcomment">; Pass a reference to the list variable to the sender.</span><br /> Set reference pfList to iList.$ref<br /> Quit method kTrue</p> <a name="squarebracketsinfieldname" /> <h3>Square Brackets in Field Name</h3> <p>For years I thought if I was using [] square brackets in the <span class="nav">Field name</span> of a <span class="code">Calculate</span> everything had to be inside the square brackets. For example:</p> <p class="code">Calculate [con('Field',Num)] as 'Some value'</p> <p>Much to my surprise, I noticed code written by another developer which had some of the text outside of the</p> <p class="code">Calculate Field[Num] as 'Some value'</p> I tested it, and it worked! Much simpler. <a name="cando" /> <h3>$cando</h3> <p>You can use <span class="code">$cando</span> to test whether or not a recipient method exists before attempting to send a message (call the method).</p> <p>A situation where I use this is when sending messages from a parent window to a contained subwindow. It might be an optional message like <span class="code">$initialize</span> or <span class="code">$setMode</span> which the subwindow may or many not have. For these situations I use <span class="code">$cando</span> to first test for a recipient method.</p> <p class="code"><span class="omcomment">; Test for recipient method in the subwindow instance.</span><br /> If rSubWin.$setMode.$cando<br /> &nbsp;&nbsp;&nbsp;<br /> &nbsp;&nbsp;&nbsp;<span class="omcomment">; The method exists, send the message.</span><br /> &nbsp;&nbsp;&nbsp;Do rSubWin.$setMode('edit') Returns FlagOK<br /> Else<br /> &nbsp;&nbsp;&nbsp;Calculate FlagOK as kTrue<br /> End If<br /> Quit method FlagOK</p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/note.gif" alt="Note" /><p>Do <strong>not</strong> add opening and closing parethesis after <span class="code">$cando()</span>. The above test would fail if we used: <span class="code">If rSubWin.$setMode.$cando()</span></p> </div> <a name="container" /> <h3>$container</h3> <p>Objects that are inside of any container field have an added property called <span class="code">$container</span>.</p> <p><span class="code">$container</span> gives you a reference to the container of the object.</p> <p>Examples of container objects are: <span class="code">kScrollbox, kGroupBox, kComplexGrid, kTabPane, kPagedPane</span></p> <p class="code"><span class="omcomment">; Set reference to a field's container.</span><br /> Set reference rContainer to rField.$container<br /> <br /> <span class="omcomment">; Using parenthesis you can get any attribute of the $container</span><br /> Calculate Name as rField.$container().$name<br /> Calculate Color as rField.$container().$forecolor</p> <a name="desc" /> <h3>$desc</h3> <p>The <span class="code">$desc</span> method has to be one of the handiest tricks I learned for doing notation.</p> <p>If you want to <span class="code">$add</span> something to a group but can't remember what all the possible parameters are, <span class="code">$decs</span> can be used to figure them out.</p> <p>Let's say you want to add a local variable to a method using notation. You know variables are in the <span class="code">$lvardefs</span> group of the method, but can't remember the parameters for <span class="code">$lvardefs.$add</span>.</p> <p>Add <span class="code">$desc</span> to the end of the notation which you know, and return the result to <span class="code">#S1</span>, then look at the value of <span class="code">#S1</span>. If you right-click on <span class="code">#S1</span> you can copy the result to the clipboard and then paste it into a comment line in your code. Handy!</p> <p>Click the <span class="nav">Run Demo</span> button in the <span class="nav">StudioTips Browser</span> to try this out. The demo code will take you to a breakpoint where you will proceed to step through the code.</p> <p class="code"><span class="omcomment">; Use the $desc property for finding out the parameters for notation.</span><br /> <br /> <span class="omcomment">; Set a reference to this class.</span><br /> Set reference rClass to $cclass<br /> <br /> <span class="omcomment">; Find out the parameters and info for adding a variable to the group.</span><br /> Do rClass.$cvardefs.$add.$desc() Returns #S1<br /> <br /> <span class="omcomment">; Hover over #S1 with your mouse to see the current value of #S1.</span><br /> Breakpoint {#S1}<br /> <br /> <span class="omcomment">; Right-click on #S1 and select "Variable #S1...". Then copy the value to the clipboard.</span><br /> <span class="omcomment">; Pasting the clipboard to a comment line(below) in your code gives you a "hard copy" of the help tip.</span><br /> <br /> <span class="omcomment">; $add(cName,type,subtype,iLength,bIsparameter) inserts a new field or variable and returns an item reference to it</span><br /> Do rClass.$cvardefs.$add('NewClassVar',kCharacter,kSimplechar,100,kFalse) Returns rVar<br /> <br /> <span class="omcomment">; Click the Variables "Class" tab to see if the "NewClassVar" now exists.</span></p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/warning.gif" alt="Warning" /><p>A method can't add an <span class="code">$lvar</span> to itself. An instance can't add an <span class="code">$ivar</span> to itself.</p> </div> <a name="fullname" /> <h3>$fullname</h3> <p class="code">$fullname</p> <p>gives the full notation path to any valid item reference.</p> <p>If you have a reference to a class or object, appending <span class="code">().$fullname</span> to the reference returns the full notation path to the class or object.</p> <p>You may ask, why did we include the open and close <span class="code">()</span> parenthesis in front of <span class="code">$fullname</span>?</p> <p>Good question!</p> <p>You can't always rely on using <span class="code">$fullname</span> without the <span class="code">()</span> prefix. In some cases it will return notation instead of the actual property name. To be safe, I've gotten into the habit of alway prefixing <span class="code">$fullname</span> with <span class="code">().</span></p> Click the <span class="nav">Run Demo</span> button in the <span class="nav">StudioTips Browser</span> to see an example. <a name="name" /> <h3>$name</h3> <p>Omnis use <span class="code">$name</span> for accessing the name property of a library, class, or object.</p> <p>If you have a reference to a class or object, adding <span class="code">().$name</span> to the reference returns the name property.</p> <p>You may ask, why did we include the open and close <span class="code">()</span> parenthesis in front of <span class="code">$name</span>?</p> <p>Good question!</p> <p>You can't always rely on using <span class="code">$name</span> without the <span class="code">()</span> prefix. In some cases it will return notation instead of the actual property name. To be safe, I've gotten into the habit of alway prefixing <span class="code">$name</span> with <span class="code">()</span>.</p> Click the <span class="nav">Run Demo</span> button in the <span class="nav">StudioTips Browser</span> to see an example. <a name="sendall" /> <h3>$sendall</h3> <p>The <span class="code">$sendall</span> method is a powerful Omnis Studio notation method. You can use <span class="code">$sendall</span> to <em>send a message to a group</em>.</p> <p>The <em>group</em> can be a group of libraries, group of classes, group of methods, group of window instances, group of window fields, group of rows in a list variable, etc.</p> <p>Any group in the Omnis Studio notation ends with the letter <em>s</em>. (<span class="code">$libs, $classes, $methods, $menus, $objs, $bobjs, $iwindows, $itasks,</span> etc.)</p> <p>To send a <span class="code">$close</span> method to all of the window instances:</p> <p class="code"><span class="omcomment">; Close all the windows.</span><br /> Do $iwindows.$sendall($ref.$close)</p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/warning.gif" alt="Warning" /><p>Prior to Omnis Studio v4.2 there was a potential problem with using <span class="code">$sendall</span> to send a call a public method, of a group of class or field instances. If the library preference <span class="code">$reportnotationerrors</span> was <span class="code">kTrue</span> and none of the objects in the group had a recipient method an error would be reported. In Omnis Studio v4.2 an optional 3rd parameter, <span class="code">bIgnoreUnrecognizedCustomAttribute=kFalse</span>, was added. Setting the 3rd parmeter to <span class="code">kTrue</span> overcomes this problem.</p> </div><p>To send a <span class="code">$saveMyData</span> message to all of the window instances:</p> <p class="code"><span class="omcomment">; Send a $saveData custom method to all windows belonging to the current task.</span><br /> Calculate bIgnoreUnrecognizedCustomAttr as kTrue<br /> Do $iwindows.$sendall($ref.$saveTheData,$ref.$task=$ctask,bIgnoreUnrecognizedCustomAttr)</p> <br /> <a name="sendallref" /> <h3>$sendallref</h3> <p><span class="code">$sendallref</span> is an item reference to the item currently receiving the message sent with <span class="code">$sendall</span>. This solves the problem with you can run into when wanting to use <span class="code">$ref</span> deeper inside a <span class="code">$sendall</span>.</p> <p>For example:</p> <p class="code"><span class="omcomment">; This $sendall will NOT work.</span><br /> Do $cinst.$bobjs.$sendall($ref.$text.$assign(StringTable.$gettext($cclass.$objs.[$ref.$ident].$text)))<br /> <br /> <span class="omcomment">; This $sendall using $sendallref WILL work.</span><br /> Do $cinst.$bobjs.$sendall($ref.$text.$assign(StringTable.$gettext($cclass.$objs.[$sendallref.$ident].$text)))</p> <p>In the first <span class="code">$sendall</span> the <span class="code">$ref.$ident</span> refers to the <span class="code">$getText</span> custom attribute of the <span class="code">StringTable</span> external component. Not what we were after.</p> <p>In the second <span class="code">$sendall</span> the <span class="code">$sendallref.$ident</span> refers to the background object receiving the message, precisely what we were after.</p> <p>The following example shows where <span class="code">$sendallref</span> is helpful when using <span class="code">$sendall</span> to group of rows in a list variable.</p> <p class="code"><span class="omcomment">; This $sendall will NOT work.</span><br /> Do List.$sendall($ref.value.$assign($ref.value+1),$ref.$selected)<br /> <br /> <span class="omcomment">; This $sendall using List instead of $ref WILL work.</span><br /> Do List.$sendall($ref.value.$assign(List.value+1),$ref.$selected)<br /> <br /> <span class="omcomment">; This $sendall using $sendallref instead of $ref WILL work.</span><br /> Do List.$sendall($ref.value.$assign($sendallref.value+1),$ref.$selected)</p> <div class="image_sideline"><img src="http://www.studiotips.net/css/images/warning.gif" alt="Warning" /><p>The <span class="code">$sendallref</span> method was added in Omnis Studio v4.2. You can not use it if you want to maintain compatibility with earlier versions of Omnis Studio.</p> </div> <p class="footer">StudioTips Documentation - Copyright 2006 Vencor Software </p></div> </body> </html>