With...End With: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Brendon (talk | contribs)
Created page with "WITH object <br /> :::[statements] <br /> END WITH '''Description''' WITH allows you to do a series of operations on an object without having to name the object each time. ..."
 
No edit summary
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
WITH object <br />
With object <br />
:::[statements] <br />
:::[statements] <br />
END WITH
End With


'''Description'''
== Description ==


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


'''Example'''
== Example ==


<pre>
<tabber>
REM WITH sample
JavaScript=
WITH document
<syntaxhighlight lang="JavaScript">
   PRINT .URL
/* With statement allows accessing properties on a specified object */
   PRINT .title
 
   PRINT .doctype
var theURL, theTitle;
END WITH
with (document) {
</pre>
  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)
);</syntaxhighlight>
|-|
BASIC=
<syntaxhighlight lang="vb.net">
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</syntaxhighlight>
</tabber>


'''Output'''
== Output ==


<pre>
<pre>
File:///C:Browse.htm
File:///C:Browse.htm
Test
New Title
[objectDocumentType]
</pre>
</pre>


'''Related Items'''
[[Category:Language Reference]]


[[class|CLASS]]
[[Category:Statements - Flow of control]]

Latest revision as of 23:40, 24 July 2019

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

/* 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)
);

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

Output

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