Author Topic: Scripting Documentation  (Read 2664 times)

Offline RJP74

  • Registered User
  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Scripting Documentation
« on: June 29, 2013, 06:25:58 PM »
In the Wiki the link for Application Object goes to a page that reads "You've followed a link to a topic that doesn't exist yet. "
So as an interim measure I wrote a script that lists the properties of "Application" etc.
It doesn't list the detailed parameters required but it is a start to know the names of the available properties.

The results are too big for this page and can be seen in the attached text file.

The basic code I used looks like this:

Code: Javascript
  1. var output = Application.Output();
  2. output.clear(); // clean output from old text
  3. output.writeln("HippoEDIT version: " + Application.Version);
  4. output.writeln("");
  5.  
  6. var results = [];
  7. var newLine = "\r\n";
  8.  
  9. function objectEnumerate(givenObject) {
  10.         var properties = [];
  11.         for (var x in givenObject) {
  12.                 properties.push(x);
  13.         }
  14.         properties.sort();
  15.         var objPropsLen = properties.length;
  16.         for (i = 0; i < objPropsLen; i++) {
  17.                 var prop = properties[i];
  18.                  results.push(prop);
  19.         }
  20. }
  21.  
  22. objectEnumerate(Application);
  23. output.writeln(results.join(newLine));
  24.  
« Last Edit: June 30, 2013, 01:42:49 AM by alex »

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2215
  • Karma: +37/-3
    • HippoEDIT
Re: Scripting Documentation
« Reply #1 on: June 30, 2013, 01:42:24 AM »
Yes, the link is pointing to nowhere :) That is from one side because nobody has asked, and I was extending API continuously and from another side has no time for adding that.
I am planning soon (maybe next week) to generate wiki pages with API from type library of hippoedit.exe. Than you will get it with parameters and some description.

But for now, to check actual API you can use something like OleView, and open type library from hippoedit.exe or two *.idl files I am adding here, which are based for generating type library.

And thanks for code, I have added it to Scripting Plugin (already uploaded), as a fast way to getting actual object/method list. Check for corresponding entry in Scripting Menu.

Updated code is like this:
Code: Javascript
  1.         var output = Application.Output();
  2.         output.clear(); // clean output from old text
  3.         output.writeln("HippoEDIT version: " + Application.Version);
  4.         output.writeln("");
  5.        
  6.         var reservedNames = {
  7.                 "AddRef":               true,
  8.                 "GetMemberName":        true,
  9.                 "GetMemberProperties":  true,
  10.                 "GetNameSpaceParent":   true,
  11.                 "GetNextDispID":        true,
  12.                 "GetTypeInfo":          true,
  13.                 "GetTypeInfoCount":     true,
  14.                 "Invoke":               true,
  15.                 "GetIDsOfNames":        true,
  16.                 "DeleteMemberByName":   true,
  17.                 "DeleteMemberByDispID": true,
  18.                 "GetDispID":            true,
  19.                 "QueryInterface":       true,
  20.                 "Release":              true,
  21.                 "RemoteInvokeEx":       true
  22.         };
  23.  
  24.         function objectEnumerate(givenObject) {
  25.                 var properties = [];
  26.                 for (var x in givenObject) {
  27.                         if ( !(x in reservedNames) )
  28.                                 properties.push(x);
  29.                 }
  30.                 properties.sort();
  31.                 return properties;
  32.         }
  33.        
  34.         function dumpObject(name, givenObject) {
  35.                 var newLine = "\r\n";
  36.                 if ( givenObject != null ) {
  37.                         output.writeln(newLine + name + newLine + "  " + objectEnumerate(givenObject).join(newLine + "  "));
  38.                 }
  39.         }
  40.        
  41.         dumpObject("Application", Application);
  42.         dumpObject("WScript", WScript);
  43.         dumpObject("Settings", Settings);
  44.         dumpObject("Document", ActiveDocument);
  45.         dumpObject("View", ActiveView);
  46.         dumpObject("Syntax", ActiveDocument.Syntax);
  47.  

Offline RJP74

  • Registered User
  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Scripting Documentation - now added to the wiki
« Reply #2 on: July 07, 2013, 04:09:16 PM »
Using Application as the base Named Object, I have added definitions of all related Named Objects to the wiki. They are defined here:
http://wiki.hippoedit.com/scripting/api/start