With...End With: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
JwellsNB (talk | contribs)
Line 34: Line 34:
   title = "New Title";
   title = "New Title";
   theTitle = title;
   theTitle = title;
   document.write(URL + "<br>");
   NSB.Print(URL);
   document.write(title + "<br>");
   NSB.Print(title);
}
}


Line 44: Line 44:
     $.title = "New Title";
     $.title = "New Title";
     theTitle = $.title;
     theTitle = $.title;
     document.write($.URL + "<br>");
     NSB.Print($.URL);
     document.write($.title + "<br>");
     NSB.Print($.title);
   }(document)
   }(document)
);
);

Revision as of 10:51, 12 May 2013

With object

[statements]

End With

Description

With allows you to do a series of operations on an object without having to name the object each time.

Example (Basic)

Rem With sample
'With statement allows accessing properties on a specified object

Dim theURL, theTitle
With document
  theURL = .URL
  .title = "New Title"
  theTitle = .title
  Print .URL
  Print .title
End With

Example (JavaScript)

// With sample
/* With statement allows accessing properties on a specified object */

var theURL, theTitle;
with (document) {
  theURL = URL;
  title = "New Title";
  theTitle = title;
  NSB.Print(URL);
  NSB.Print(title);
}

/* a better way to perform With */

(function($){
    theURL = $.URL;
    $.title = "New Title";
    theTitle = $.title;
    NSB.Print($.URL);
    NSB.Print($.title);
  }(document)
);

Output

File:///C:Browse.htm
New Title