Tapatalk

UltraEdit.activeDocument.timeDate()

UltraEdit.activeDocument.timeDate()

6
NewbieNewbie
6

    Sep 17, 2008#1

    This script takes some input and creates an Oracle create user statement. I'm having trouble getting the date to appear after two dashes (comment)

    Code: Select all

    var input = UltraEdit.getString("enter 'ora_user first last' (ie 'C12345 Tom Slick')", 1);
    
    var sep = " ";
    var input_arr = new Array();
    input_arr = input.split(sep);
    
    var username = input_arr[0];
    var person_name = input_arr[1] + " " + input_arr[2];
    
    UltraEdit.activeDocument.write("--------------------------------------------------------------------------------\r\n");
    UltraEdit.activeDocument.write("--" + UltraEdit.activeDocument.timeDate() + "\r\n");
    UltraEdit.activeDocument.write("\r\n");
    UltraEdit.activeDocument.write("create user " + username + " identified by password /* " + person_name + " */\r\n");
    UltraEdit.activeDocument.write("profile default\r\n");
    UltraEdit.activeDocument.write("password expire\r\n");
    UltraEdit.activeDocument.write("default tablespace the_tablespace\r\n");
    UltraEdit.activeDocument.write("temporary tablespace temp\r\n");
    UltraEdit.activeDocument.write(";\r\n");
    UltraEdit.activeDocument.write("grant create session to " + username + ";\r\n");
    UltraEdit.activeDocument.write("grant select_all_role to " + username + ";\r\n");
    
    I'm getting is this: (see bold)

    --------------------------------------------------------------------------------
    09/17/2008 2:47:58 PM--true

    create user c12345 identified by password /* test user */
    profile default
    password expire
    default tablespace the_tablespace
    temporary tablespace temp
    ;
    grant create session to c12345;
    grant select_all_role to c12345;

    I want is this: (see bold)

    --------------------------------------------------------------------------------
    --09/17/2008 2:47:58 PM

    create user c12345 identified by password /* test user */
    profile default
    password expire
    default tablespace the_tablespace
    temporary tablespace temp
    ;
    grant create session to c12345;
    grant select_all_role to c12345;


    I'm not sure where the "true" is coming from and cannot figure out why the dash string is being written after the timeDate().

    Any help would be greatly appreciated

    TD

    262
    MasterMaster
    262

      Sep 17, 2008#2

      It's because timeDate() writes directly into the active document when invoked. And directly following that you "ask" if the function exists and it returns "true" which is then also added to the document as '--true'.

      The correct way to write it is:

      Code: Select all

      ...
      UltraEdit.activeDocument.write("--");
      UltraEdit.activeDocument.timeDate();
      UltraEdit.activeDocument.write("\r\n");
      ...

      6
      NewbieNewbie
      6

        Sep 18, 2008#3

        nicely done.... thanks