Loading ...
Sorry, an error occurred while loading the content.

Unused variable Function Defined But Called By eval'd call

Expand Messages
  • jamrsim@yahoo.com
    I understand eval is evil, but unfortunately have to use it. Given that ... I d like to be error free by acknowledging this was reviewed and accepted. I have a
    Message 1 of 3 , May 20, 2011
    • 0 Attachment
      I understand eval is evil, but unfortunately have to use it.

      Given that ... I'd like to be error free by acknowledging this was reviewed and accepted.

      I have a function defined in my .js program. An AJAX call retrieve's a list which creates YUI buttons. Each button has a call to said function. Because jslint cannot see the effects of the eval (runtime), jslint is (I believe) giving me an 'Unused variable' error. Although, it truly is used.

      Is there a suitable preprocessor to indicate, yes, I understand, but it is being used and jslint merely can't see the use because I have to use the evil eval.

      /*jslint unvar: false*///turn it off
      var myvar;
      /*jsline unvar: true*///turn it back on
    • Douglas Crockford
      ... That seems unlikely.
      Message 2 of 3 , May 21, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, jamrsim@... wrote:
        >
        > I understand eval is evil, but unfortunately have to use it.

        That seems unlikely.
      • jamrsim@yahoo.com
        ... Thanks for the reply. I will presume you are correct and I need to figure out a way around my eval. However, in a similar vein, what is the best practice
        Message 3 of 3 , May 23, 2011
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
          wrote:
          >
          > --- In jslint_com@yahoogroups.com, jamrsim@ wrote:
          > >
          > > I understand eval is evil, but unfortunately have to use it.
          >
          > That seems unlikely.
          >

          Thanks for the reply.

          I will presume you are correct and I need to figure out a way around my
          eval.

          However, in a similar vein, what is the best practice for a pre-defined
          function (YUI Library) where my custom code does not use one of the
          defined parameters being passed to my function. This too, yields and
          unused variable message.

          Error: Unused variable: oColumn 127 'addWrench'

          formatter - String ||
          HTMLFunction
          Cell formatter function, or a shortcut pointer to a function in
          theDataTable.Formatter object. The function, called from the
          DataTable'sformatCell method, renders markup into the cell linerelement
          and accepts the following arguments:elLinerThe element to write
          innerHTML to.oRecordThe associated Record for the row.oColumnThe Column
          instance for the cell.oDataThe data value for the cell.
          For example:
          .
          .
          addWrench = function (el, oRecord, oColumn, oData) {
          el.innerHTML = oData;
          if (oRecord.getData('spacer') === 'OpenLabor') {
          el.innerHTML += ' <img src="/images/wrench.png" title="Tech
          currently clocked on the job">';
          }
          },
          .
          .
          // Datatable column definition
          dtCols = [
          {key: "field"},
          {key: "description", formatter: addWrench},
          .
          .

          Thanks Again!



          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.