[MacEd] New MacroEditor (2003.1223)

Biju G C bijumaillist at yahoo.com
Tue Dec 23 17:44:42 EST 2003


New MacroEditor (2003.1223) available at
http://downloads.mozdev.org/macroeditor/MacroEditor.xpi

but need more testing.
pl. test it an report any bug, before we announce to public.

To make coding of macro easier i have made 
a new object available called "MacroUtils"

macro developers can use its methods to do
most common operations. Most methods available 
are not something new but only a wraper for existing
functionality in moz/fb/tb and jslib

MacroEditor 2003.1223 is jslib enabled
if user install jslib more feature are available,
ie, class like file,dir,fileutils,dirutils, all rdf classes
(for other jslib classes you need an extra include statment)

While coding I am always confused of upper/lower case 
of function names, so for all the functions here I have given
a name (pretty name) and an alias name in lowercase. 
And for properties all in lowercase. 
This will be the standard
(exepect where it is unavoidable)

eg function "runMacroById" can also be called 
by name "runmacrobyid"

function definetions

  MacroUtils.runMacroById(macro_num) or
  MacroUtils.runmacrobyid(macro_num)

calls another macro by id, another macro can be active/inactive
(internaly this invoke our old MacroMenu.oncommand)

  MacroUtils.runMacroByName(macro_name)
  MacroUtils.runmacrobyname(macro_name)

calls another macro by name, another macro can be active/inactive
first it check for exact match, 
if not found do trimed match
if not found do case insensitive match

  MacroUtils.urlRead(url) or
  MacroUtils.urlread(url)  

reads and returns a remote html/js/xml/txt page a text

eg: alert(MacroUtils.urlRead("http://yahoo.com")) to return source of 
the yahoo home page

or alert(MacroUtils.urlRead("http://macroeditor.mozdev.org/testinsecure.js"))

it can even read local files
eg: alert(MacroUtils.urlRead("C:\\autoexec.bat")) 
or  alert(MacroUtils.urlRead("file:///C:/autoexec.bat")) 


  MacroUtils.runInsecureJS(url)
  MacroUtils.runinsecurejs(url) 

execute a remote javascript
eg MacroUtils.runInsecureJS("http://macroeditor.mozdev.org/testinsecure.js")

it can also run a local file
   MacroUtils.runInsecureJS("file:///C:/testinsecure.js")
or MacroUtils.runInsecureJS("C:\\testinsecure.js")


  MacroUtils.set2String(set, filter)
  MacroUtils.set2string(set, filter)

list all property/method of an object along with value
(filter is optional)

eg:  alert(MacroUtils.set2String(window, "get"))
list all method/properties of window object with word "get" in the name


  MacroUtils.set2List(set, filter)
  MacroUtils.set2list(set, filter)

similar to set2String but only names in a string array
eg: alert(MacroUtils.set2List(window, "get"))


  MacroUtils.urlFromDOSPath(path)
  MacroUtils.urlfromdospath(path)

retuns "file:///" equivalent of dos path

eg: alert(MacroUtils.urlFromDOSPath("C:\\autoexec.bat")) 
 show "file:///C:/autoexec.bat"


  MacroUtils.jslib 

"true" if there is JSLib installed else "false"


following methodes are only available if JSLib is installed
else some retun "false" or "" or 0 or throws error
for extra info read http://jslib.mozdev.org/docs.html
You can get all these functionality by just uing jslib objects.
Reason why these function is given is to reduce line of code in
macro. example to read a file in jslib is 4 statements
but with MacroUtils you can do it in a single statement.
same case for file write


  MacroUtils.runApp(aPath, aArgs) 
  MacroUtils.runapp(aPath, aArgs) 

to run an external app from macro 
eg: 
MacroUtils.runApp("C:\\WINXP\\notepad.exe")
MacroUtils.runApp("C:\\Windows\\notepad.exe")
MacroUtils.runApp("C:\\Winnt\\notepad.exe")

optionally you can pass arguments


  MacroUtils.getPathSeparator() 
  MacroUtils.getpathseparator()

on window retuns "\"
on unix retuns "/"

  MacroUtils.ensureParentDirs(path) 
  MacroUtils.ensureparentdirs(path)

before writing a file JSLib wants the parent dir to be present
ensureParentDirs creates all parent dirs if not present
retun false if not sucessfull

eg: MacroUtils.ensureParentDirs("c:\\xxx\\yyy\\test.txt") 
creates c:\xxx\yyy\ and c:\xxx\yyy\ dir


  MacroUtils.fileWrite(path, contents, makeparents) 
  MacroUtils.filewrite(path, contents, makeparents) 

write "contents" to a file.
"makeparents" is optional, a value of true creates parent dir 
if not present

eg:  MacroUtils.fileWrite("C:\\macrowrite.txt","test matter\n")
  MacroUtils.fileWrite("C:\\xxx\\zzz\\macrowrite.txt","test matter\n", true)

  MacroUtils.fileappend(path, contents, makeparents)
  MacroUtils.fileAppend(path, contents, makeparents) 

same as "fileWrite" but append new contents instead of overwrite
if the file dont exist new file is created

eg:  MacroUtils.fileWrite("C:\\macrowrite.txt","some more matter\n")


  MacroUtils.fileRead(path) 
  MacroUtils.fileread(path) 

eg:  alert(MacroUtils.fileRead("C:\\macrowrite.txt"))
   shows content of C:\macrowrite.txt


I am skipping few as they are self explanatory

  MacroUtils.fileDel(path) 
  MacroUtils.filedel(path) 

  MacroUtils.isFile(path) 
  MacroUtils.isfile(path) 

  MacroUtils.fileExists(path) 
  MacroUtils.fileexists(path) 

  MacroUtils.fileSize(path) 
  MacroUtils.filesize(path) 

  MacroUtils.fileDateModified(aPath) 
  MacroUtils.filedatemodified(aPath) 

  MacroUtils.fileName(aPath) 
  MacroUtils.filename(aPath) 

  MacroUtils.fileCopy(aSource, aDest)
  MacroUtils.filecopy(aSource, aDest)

  MacroUtils.fileMove(aSource, aDest)
  MacroUtils.filemove(aSource, aDest)


  MacroUtils.dirMake(aPath, aPermissions) 
  MacroUtils.dirmake(aPath, aPermissions) 

  MacroUtils.isDir(aPath) 
  MacroUtils.isdir(aPath) 

  MacroUtils.dirExists(aPath) 
  MacroUtils.direxists(aPath) 

  MacroUtils.dirDel(aPath, aRecursive) 
  MacroUtils.dirdel(aPath, aRecursive)

  MacroUtils.dirMove(aSource, aDest) 
  MacroUtils.dirmove(aSource, aDest) 


  MacroUtils.dirRead(aPath,aRegExpFilter)
  MacroUtils.dirread(aPath,aRegExpFilter)

returns content of dir in an array of objects
eg: alert(MacroUtils.dirRead("c:\\"));

optionally a RegExp Filter
eg: alert(MacroUtils.dirRead("c:\\", /autoexec/i));

  
  MacroUtils.dirreadnames(aPath,aRegExpFilter)
  MacroUtils.dirReadNames(aPath,aRegExpFilter)
  
returns content of dir in a string array of names
eg: alert(MacroUtils.dirReadNames("c:\\"));

optionally a RegExp Filter  
eg: alert(MacroUtils.dirReadNames("c:\\", /autoexec/i));



________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html


More information about the MacroEditor mailing list