<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Aha! That's exactly the sort of syntax I was looking for! :)<div><br></div><div>I just couldn't find any examples of the DRL syntax for 'creating' a value like that in the LHS. A quick test with a contrived little example shows me that the following works:</div><div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">rule "Warn when my meal is too large"</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">when</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp;&nbsp;$meal: Meal($calories: calories &gt; 1000)</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp;&nbsp;$unit: String() from "calories"</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">then</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp;&nbsp;insert(new MealTooBigWarning("That meal is bigger than your 1000 " + $unit + " limit."));</div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">end</div></div></blockquote><div><br></div><div>So, based on that I'm able to write a DSL like this:</div><div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><div style="margin: 0px; "><div style="margin: 0px; ">[when][]I am given a meal of more than "{sizeLimit}" "{unit}" = $meal: Meal($size: {unit} &gt; {sizeLimit}); $sizeLimit: Integer() from {sizeLimit}; $unit: String() from "{unit}"</div></div></div></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><div style="margin: 0px; "><div style="margin: 0px; ">[then][]Warn that the meal is too big = insertLogical(new MealTooBigWarning("That meal is bigger than your " + $sizeLimit + " " + $unit + " meal limit."));</div></div></div></div></blockquote><div><div><br></div><div>Which means that I can write DSLR like this:</div><div><br></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">rule "Warn when my meal has too many calories"</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">when</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; I am given a meal of more than "1000" "calories"</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">then</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; Warn that the meal is too big</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">end</div></div></div></blockquote><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><br></div><div style="margin: 0px; min-height: 15px; ">… which gives me:</div><div style="margin: 0px; min-height: 15px; "><br></div></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><div style="margin: 0px; ">That meal is bigger than your 1000 calories meal limit.</div></div></div></div></blockquote><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><br></div><div style="margin: 0px; min-height: 15px; ">Or this:</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px; "><br></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">rule "Warn when my meal has too many diet club points"</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">when</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; I am given a meal of more than "11" "dietClubPoints"</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">then</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">&nbsp; &nbsp; Warn that the meal is too big</div></div></div><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">end</div></div></div></blockquote><div><div><br></div><div>… which gives me:</div><div><br></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; ">That meal is bigger than your 11 dietClubPoints meal limit.</div></div></div></blockquote><div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><br></div></div><div style="margin: 0px; "><div style="margin: 0px; ">So I can define an enumeration:</div><div style="font-size: 11px; font-family: Monaco; margin: 0px; "><br></div></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div style="margin: 0px; "><div style="font-size: 11px; font-family: Monaco; margin: 0px; ">'MealSize.units': ['calories=calories', 'dietClubPoints=diet club points']</div></div></div></blockquote><div><div><br></div><div>So that in Guvnor, I have a single sentence with a drop-down menu containing the options "calories" and "diet club points". That keeps things nice and clean for the users.</div><div><br></div><div>Thanks for the pointer.</div><div><br></div><div>Steve</div><div><br></div><div><br></div><div>ps - My 'real' application is validating different types of exposure limits for a hedge fund, but the examples above seemed a bit more readable for anybody who doesn't work for a hedge fund. :)<br><div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><br></div><div><br><div><div>On 4 Jun 2013, at 17:18, Davide Sottara &lt;<a href="mailto:dsotty@gmail.com">dsotty@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
  
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">The usual (and only reasonable way) to
      "set" a variable in the LHS is to bind it to a Drools variable, <br>
      including things like:<br>
      <br>
      ...<br>
      $x : String() from /* expression here */<br>
      ...<br>
      <br>
      any usage of the "=" operator is generally suspicious.. <br>
      but I'm not sure I have understood your use case completely.. :)<br>
      <br>
      <br>
      <br>
      On 06/04/2013 05:59 PM, Stephen Masters wrote:<br>
    </div>
    <blockquote cite="mid:15BB52DC-E304-483F-9BA5-274897C59B8F@me.com" type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <div>Thanks for the cheat idea Mike.&nbsp;I wasn't really expecting any
        help from the tooling itself. Just hoping that there might be
        some trickery within the DSL that I could try, to generate some
        code which would set up a variable for me.</div>
      <div><br>
      </div>
      <div>Unfortunately I do need to combine LHS sentences and multiple
        RHS sentences, so your idea isn't really an option in this case.
        :(</div>
      <div><br>
      </div>
      <div>As it is I have created a little enumeration in the RHS
        sentence, and it's not looking too bad. At least, with some
        selective wording, it doesn't look completely redundant!</div>
      <div><br>
      </div>
      <div>Steve</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <br>
      <div>
        <div>On 4 Jun 2013, at 16:33, Michael Anstis &lt;<a moz-do-not-send="true" href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>&gt;
          wrote:</div>
        <br class="Apple-interchange-newline">
        <blockquote type="cite">
          <div dir="ltr">
            <div>
              <div>
                <div>This would need to be provided by the tooling; I
                  don't think it's something that's even remotely
                  possible at runtime (unless you stored the field name
                  in a Fact and used reflection on the RHS).<br>
                  <br>
                </div>
                That said (and you're going to guess my next comment)
                this is not provided in the guided editors. Depending on
                how complex your DSLs are and whether users need to
                combine DSL Sentences; IDK if a "cheat" works:<br>
                <br>
              </div>
              [when]Do something with {field} and {value}=$f :
              Fact({field}=={value} then $f.{field} = {value}<br>
              <br>
            </div>
            I've not tried it; nor know whether it fits your
            requirements.. but a hack worth trying?<br>
          </div>
          <div class="gmail_extra"><br>
            <br>
            <div class="gmail_quote">On 3 June 2013 17:40,
              stephen.masters <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:stephen.masters@me.com" target="_blank">stephen.masters@me.com</a>&gt;</span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div>
                  <div>Hi folks,</div>
                  <div><br>
                  </div>
                  <div>Is there a decent way to set a value in the LHS
                    of a rule so that it's available in the RHS?</div>
                  <div><br>
                  </div>
                  <div>Reason being I have a DSL driving the guided
                    rules editor which will pluck out the value of a
                    field, where the name of that field is driven by a
                    drop down menu enumeration.</div>
                  <div><br>
                  </div>
                  <div>A change I now have would be a lot easier if I
                    could assign a string to a variable in the LHS,
                    which could be read by the RHS. Otherwise I might
                    need to extend the RHS DSLs to include the same
                    enumeration as the LHS. Which looks a bit redundant
                    for a business user wondering why the need to write
                    the same thing twice.</div>
                  <div><br>
                  </div>
                  <div>Any thoughts?</div>
                  <div><br>
                  </div>
                  <div>Steve</div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div>
                    <div style="font-size:75%;color:#575757">Sent from
                      Samsung Mobile</div>
                  </div>
                </div>
                <br>
                _______________________________________________<br>
                rules-users mailing list<br>
                <a moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
                <a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
              </blockquote>
            </div>
            <br>
          </div>
        </blockquote>
      </div>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
    </blockquote>
    <br>
  </div>

_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users</blockquote></div><br></div></div></div></div></div></body></html>