capt webb
Capt. Horatio T.P. Webb
 
Mid-Term Study Guide
[ Minimally -- what to Understand for the Midterm ]

MIS 3371 Transaction Processing I -- Parks
Version 5 -- Last Updated 12:09 PM THU 8/15/2018


 

  • Part A. HTML (links)
  • Part B. SCRIPTING (links)
  • See HTML scripting sample pages:
    Part I (radio, select, checkbox) and Part II (more)
    Use the right side of the help pages below
    ("javascript is on the right half, "vbscript" on the left))

    PART A. HTML

    For more HTML details see the Bare Bones Guide

    PART B. Scripting
    VBScript and Javascript
    See my IF statements page for more details
    See my LOOPS statements page for more details
    See my SEQUENTIALS statements page for more details
    See my Scripting Declaration Summary
     
    VBScript
     
     
    Javascript
     
    if <condition> then .
    .
    .
    zero or more vbsvript statements to excecute
    when the <condition> is true .
    .
    .
    else
    .
    .
    .
    zero or more vbsvript statements to excecute
    when the <condition> is false .
    .
    .
    end if

    <conditions>

    • variable or constant = variable or constant
    • variable or constant < > variable or constant
    • variable or constant <= variable or constant
    • variable or constant >= variable or constant
    • variable or constant < variable or constant
    • variable or constant > variable or constant
    if (<condition>)
    {
    .
    .
    .
    zero or more javascript statements to excecute
    when the <condition> is true .
    .
    .
    }
    else
    {
    .
    .
    .
    zero or more javascript statements to excecute
    when the <condition> is false .
    .
    .
    }

    <conditions>

    • variable or constant == variable or constant
    • variable or constant != variable or constant
    • variable or constant <= variable or constant
    • variable or constant >= variable or constant
    • variable or constant < variable or constant
    • variable or constant > variable or constant
    for subscript = start_value TO stop_value [ BY increment]
    .
    .
    .
    zero or more vbscript statements to excecute
    .
    .
    .
    next

    • subscript will be an integer
    • start_value must be an integer
    • stop_value must be an integer
    • increment must be an integer
    for (subscript = start_expression ; stop_condition ; increment expression)
    {
    .
    .
    .
    one or more javascript statements to excecute
    .
    .
    .
    }

    • start_expression must assign the subscript an integer value
    • stop_condition may be any true-false condition. the loop is executed so long as the condition is true
    • increment_expression should change the value of the subscripittypical increment_expression are:
      • subscript++
      • subscript--
      • subscript=subscript + integer (e.g., i = i + 2 )
      • subscript=subscript - integer (e.g., i = i - 2 )

    The { and } are NOT required -- if there is only one statement to execute inside the loop.

    String Search Function -- INSTR

    INSTR (start_location, string_to_search, string_to_search_for[, case_match])

    Used to find the starting location of a string (the string_to_search_for) in a string (string_to_search)

    • start_location -- the number of the character (i.e., its location) in the string_to_search WHERE you wish to begin the search. vbscript string begin numbering the characters in the string at 1.
    • string_to_search and string_to_search_for may be variables that contain a string OR quoted strings.
    • case_match is optional. 0 means case sensitive (exact matches only) and a 1 means case insensitive (exact matches only). The default (i.e., if you don't specify this value) is exact matches only.
    • INSTR returns the integer. If the string_to_search_for is NOT found in string_to_search, the function returns a 0.
    Code to find multiple occurences:

      txt="the string to search"
      searchfor="the string to search for"
      count=0
      loc=1
      Do While instr(loc,tx,searchfor) > 0
         count = count + 1
         loc=instr(loc,tx,searchfor)+1
      Loop
    

    search this string
    for this string
    String Search Method -- .indexOf (and .charAt)

    string_to_search.indexOf( string_to_search_for , start_location )

    Used to find the starting location of a string (the string_to_search_for) in a string (string_to_search)

    • start_location -- the number of the character in the string_to_search WHERE you wish to begin the search. javascript string begin numbering the characters in the string at 0.
    • string_to_search and string_to_search for may be variables that contain a string OR quoted strings.
    • indexOf returns the integer. If the string_to_search_for is NOT found in string to search, the function returns a -1.

    Code to find multiple occurences:

       txt="the string to search"
       searchfor="the string to search for"
       count=0;
       loc=0;  // start searching at character 0
       while (txt.indexOf(searchfor,loc) != -1)
         {
          count++;
          loc=txt.indexOf(searchfor,loc)+1;
         }
    

    search this string
    for this string
    String Extract Function -- MID

    Returns number_of_characters_to_retreive starting at start_location

    MID (string_to_search , start_location , number_of_chars_to_retreive)

    If number_of_chars_to_retreive is omitted, all the characters beginning at start_location are returned.

    String Extract Method .substr

    Returns number_of_chars_to_retreive starting at the position start_location

    string_to_search.substr( start_location , number_of_chars_to_retrieve );

    If number_of_chars_to_retreive is omitted, all the characters beginning at start_location are returned.

    A variariant of .substr (i.e., retrieve a string at some location) is .charAt (retrieve ONE character from a specific location)

    usgae is:

    string_to_search.charAt( string_location);

    string_location must be an interger > = 0.

    String Replace Function -- REPLACE

    Returns a string with some characters replaced.

    REPLACE ([start_location,] string_to_search , string_to_replace , replacement_search , start_location [, number_of_replacements)]

    • start_location is optional. If omitted, the search begins at the first character (location=1)
    • If number_of_replacements is omitted, all occurences of string_to_replace are replaced by replacement_search.
    String Replace Method -- .replace

    Returns a string with some characters replaced.

    string_to_search.replace( string_to_replace , replacment_string );

    • the .replace method ONLY performs the replacement ONCE

    String Split Function -- SPLIT

    Divides a string into parts based on the occurrence of some string AND creates a zero-based array to store them.

    name_for_the_new_array = SPLIT (string_to_split , string to define split positions(s) , count)

    • string to define split positions(s) is NOT stored in the resulting array
    • count specifies the maximun numbner of array elements to return
    String Extract Method -- .split

    Divides a string into parts based on the occurrence of some string AND creates a zero-based array to store them.

    name_for_the_new_array = string_to_split.split (string to define split positions(s))

    • string to define split positions(s) is NOT stored in the resulting array

    Array Declarations in VBScript

    DIM name_of_the_array( total_number-of_items - 1 )

    • the array is zero-based.
    • the first element is name_of_the_array (0)
    • the last element is name_of_the_array (total_number-of_items - 1 )

      e.g., DIM fred(4) would create five elements: fred(0), fred(1), fred(2), fred(3), fred(4)

    • you can access:

      the location of the lowest location number (i.e., subscript) by using:

      lbound( name_of_the_array )

      lbound returns an integer

      the location of the highest location number (i.e., subscript) by using:

      ubound( name_of_the_array )

      ubound returns an integer

    • You can declare AND initialize an array by using:

      name_of_the_array = Array ( 1st value , 2nd value , ... )

      For example:

      fred = Array ("TX","AR",123,"CA", "breakfast")

    Array Declarations in Javascript

    var name_of_the_array = new Array( total_number-of_items )

    • the array is zero-based.
    • the first element is name_of_the_array [ 0 ]
    • the last element is name_of_the_array [total_number-of_items - 1 ]

      e.g., var fred = new Array(4) would create five elements: fred[0], fred[1], fred[2], fred[3], fred[4]

    • you can access:

      the location of the highest location number (i.e., subscript) by using:

      name_of_the_array.length

      which returns an integer

    • You can also declare an array WITHOUT specifying EXACTLY how many elements like this:

      var name_of_the_array = new Array()

      OR this:

      var name_of_the_array = [ ]

    • You can declare AND initialize an array like this:

      var name_of_the_array = new Array ( 1st value , 2nd value , ... )

      OR this:

      var name_of_the_array = [ 1st value , 2nd value , ... ]

      For example:

      var fred = new Array ("TX","AR",123,"CA", "breakfast")

      OR

      var fred = ["TX","AR",123,"CA", "breakfast"]

    page on-the-fly

    document.open
    document.clear
    document.write "<HTML>..."
    document.write "string"
    .
    . these strings produce a well formed HTML page
    .
    document.write "string"
    document.write "...</HTML>"
    document.close

    page on-the-fly

    document.open();
    document.clear();
    document.write ("<HTML>...");
    document.write ("string");
    .
    . these strings produce a well formed HTML page
    .
    document.write ("string");
    document.write ("...</HTML>")
    document.close();