UltraEdit.activeDocument.timeDate()

Help with writing and running scripts

UltraEdit.activeDocument.timeDate()

Postby todwith1d » Wed Sep 17, 2008 1:59 pm

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
todwith1d
Newbie
 
Posts: 4
Joined: Thu May 22, 2008 4:53 am

Re: UltraEdit.activeDocument.timeDate()

Postby jorrasdk » Wed Sep 17, 2008 3:45 pm

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");
...
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark

Re: UltraEdit.activeDocument.timeDate()

Postby todwith1d » Thu Sep 18, 2008 6:07 am

nicely done.... thanks
todwith1d
Newbie
 
Posts: 4
Joined: Thu May 22, 2008 4:53 am


Return to Scripts