{"id":19232955,"url":"https://github.com/mikeduglas/activescripting","last_synced_at":"2026-06-15T12:32:11.807Z","repository":{"id":94835645,"uuid":"269098001","full_name":"mikeduglas/ActiveScripting","owner":"mikeduglas","description":"Active Scripting for Clarion","archived":false,"fork":false,"pushed_at":"2023-01-26T13:41:45.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T11:41:44.373Z","etag":null,"topics":["clarion","javascript","jscript","regular-expressions","search","vbscript","windows-search","wmi"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikeduglas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-03T13:38:50.000Z","updated_at":"2024-09-05T08:45:58.000Z","dependencies_parsed_at":"2023-06-03T13:03:31.484Z","dependency_job_id":null,"html_url":"https://github.com/mikeduglas/ActiveScripting","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mikeduglas/ActiveScripting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeduglas%2FActiveScripting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeduglas%2FActiveScripting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeduglas%2FActiveScripting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeduglas%2FActiveScripting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikeduglas","download_url":"https://codeload.github.com/mikeduglas/ActiveScripting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeduglas%2FActiveScripting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34363538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clarion","javascript","jscript","regular-expressions","search","vbscript","windows-search","wmi"],"created_at":"2024-11-09T16:08:15.112Z","updated_at":"2026-06-15T12:32:11.791Z","avatar_url":"https://github.com/mikeduglas.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveScripting\r\n\r\nHow to run VBScript and get a result? You can RUN(‘file.vbs’) and parse output file to obtain a result, but there is another approach: [Active Scripting](https://en.wikipedia.org/wiki/Active_Scripting).\r\n3 scripting engines are installed by default: VBScript, JScript and [ChakraJS](https://en.wikipedia.org/wiki/Chakra_(JScript_engine)), and can be easily used in Clarion applications.\r\n\r\nVBScript, areas of use:\r\n- Active Directory\r\n- ADO\r\n- Computer Hardware\r\n- Group Policy\r\n- IIS\r\n- Logs\r\n- Mathematics\r\n- Messaging and Communication\r\n- Microsoft Office\r\n- Networking\r\n- Operating System\r\n- Other Directory Services\r\n- Printing\r\n- Security\r\n- Service Packs and Hot Fixes\r\n- Storage\r\n- Terminal Server\r\n- WMI\r\n\r\n[Demo application](https://yadi.sk/d/pF49IbwH_JEh4g) allows to run scripts and evaluate expressions.\r\n\r\n### Requirements\r\n- C63. and higher, ABC/Clarion\r\n- No blackbox\r\n- No 3rd parties\r\n- No dependencies (VC++, .NET and so on)\r\n\r\n### Price\r\n- Core classes: $200 \r\n- Add-ons (WMI, ADO, RegEx, Windows Search): $30 for each add-on\r\n- Full: $300\r\n\r\n**Search for \"Active Script\" on Clarionshop.**\r\n\r\n### Contacts\r\nmikeduglas@yandex.ru\r\n\r\n#### VBScript examples.\r\n1. Calculator:\r\ntype an expression like \"0.75 / 4\" or \"sqr(5) + log(13)\" and press Evaluate expression button.\r\n\r\n2. Reusable scripts:\r\npaste following code (the Fibonacci numbers function) into script text box and press Run script button:\r\n\r\n\u003e     function fibonacci(limit)\r\n\u003e       dim a,b,c,res\r\n\u003e       a=0\r\n\u003e       b=1\r\n\u003e       res=\"Fibonacci numbers from 1 to \"\u0026 limit \u0026 vbCrLf\r\n\u003e \r\n\u003e       for i=1 to limit\r\n\u003e         c=a+b\r\n\u003e         a=b\r\n\u003e         b=c\r\n\u003e         res=res \u0026 c \u0026 vbCrLf\r\n\u003e       next\r\n\u003e \r\n\u003e       fibonacci=res\r\n\u003e     end function\r\n\r\nthen you can evaluate \"fibonacci\" function many times with different arguments, for example type \"fibonacci(10)\" and press Evaluate expression button, \r\nnext time type \"fibonacci(20)\" and press Evaluate expression button.\r\n\r\nSame is true for JScript and [ChakraJS](https://en.wikipedia.org/wiki/Chakra_(JScript_engine)).\r\n\r\n#### Practical use of Active Scripting: Regular Expressions.\r\n\r\nClarion has a very limited support of regular expressions. With javascript we can use the full power of regular expressions:\r\n\r\nsearch for a match between a regular expression and a specified string\r\nreplace some or all matches\r\nturn a string into an array of strings, by separating the string at each instance of a specified separator string\r\nAn example of replace feature:\r\n\r\n\u003e     var name1 = 'John Smith';\r\n\u003e     var re = /(\\w+)\\s(\\w+)/;\r\n\u003e     var name2 = name1.replace(re, '$2, $1');  // expected result: 'Smith, John'\r\nAn example of split feature:\r\n\r\n\u003e     var s = 'Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ';\r\n\u003e     var re = /\\s*(?:;|$)\\s*/;\r\n\u003e     var arr = s.split(re);\r\n\r\nI wrote a class that implements js regular expressions properties and methods:\r\n\r\n- Test - returns true if match found\r\n- Exec - returns an array of matches\r\n- Match - returns an array of matches\r\n- Search - returns the index of the first match\r\n- Replace - returns a new string with some or all matches of a pattern replaced by a replacement\r\n- ReplaceFunction - uses a function to be invoked to create the new substring\r\n- Split - returns an array of strings, split at each point where the separator occurs in the given string\r\n- LastIndex - the index at which to start the next match\r\n\r\nso examples above can be written in Clarion like this:\r\n\r\n\u003e       re.CreateNew('(\\w+)\\s(\\w+)')\r\n\u003e       name = re.Replace(s, '$2, $1')\r\n\r\nand this\r\n\r\n\u003e       re.CreateNew('\\s*(?:;|$)\\s*')\r\n\u003e       len = re.Split(s)\r\n\u003e       LOOP i = 1 TO len\r\n\u003e         name = re.MatchedItem(i)\r\n\u003e       END\r\n\r\n#### Practical use of Active Scripting: [ADO](https://en.wikipedia.org/wiki/ActiveX_Data_Objects).\r\n\r\nFor example, let’s see how to extract data from Microsoft Access database using VBScript (you can test it in the demo program):\r\n\r\n\u003e       ' open connection\r\n\u003e       Dim conn\r\n\u003e       Set conn = CreateObject(\"ADODB.Connection\")\r\n\u003e       conn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=address.mdb\"\r\n\u003e       \r\n\u003e       ' execute SQL query and get recordset\r\n\u003e       Dim rs\r\n\u003e       Set rs = CreateObject(\"ADODB.Recordset\")\r\n\u003e       rs.Open \"SELECT * FROM address\", conn\r\n\u003e       \r\n\u003e       Do Until rs.EOF\r\n\u003e         MsgBox \"CustomerID=\"\u0026 rs.Fields(\"CustomerID\") \u0026\"; Company=\"\u0026 rs.Fields(\"Company\")\r\n\u003e         rs.MoveNext\r\n\u003e       Loop\r\n\u003e       \r\n\u003e       Set rs = nothing\r\n\u003e       Set conn = nothing\r\n\r\nHere is same task implemented with helper class:\r\n\r\n\u003e       !- open connection\r\n\u003e       IF ado.conn.Open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=address.mdb') = adStateOpen\r\n\u003e       \r\n\u003e         !- execute SQL query and get recordset\r\n\u003e         IF ado.rs.Open('SELECT * FROM address') = adStateOpen\r\n\u003e       \r\n\u003e           !- loop through recordset and store field values into quueue\r\n\u003e           LOOP WHILE NOT ado.rs.EOF()\r\n\u003e             CLEAR(AddrQ)\r\n\u003e             Adr:CustomerID = ado.rs.Field('CustomerID')\r\n\u003e             Adr:Company    = ado.rs.Field('Company')\r\n\u003e             Adr:Street     = ado.rs.Field('Street')\r\n\u003e             ADD(AddrQ)\r\n\u003e       \r\n\u003e             !- next record\r\n\u003e             ado.rs.MoveNext()\r\n\u003e           END\r\n\u003e             \r\n\u003e           !- close recordset\r\n\u003e           ado.rs.Close()\r\n\u003e         ELSE\r\n\u003e           MESSAGE('Recordset.Open failed')\r\n\u003e         END\r\n\u003e           \r\n\u003e         !- close conection\r\n\u003e         ado.conn.Close()\r\n\u003e       ELSE\r\n\u003e         MESSAGE('Connection.Open failed')\r\n\u003e       END\r\n\r\n#### Practical use of Active Scripting: [WMI](https://en.wikipedia.org/wiki/Windows_Management_Instrumentation)\r\n\r\nShort list of WMI tasks:\r\n\r\n- BIOS information\r\n- Display configuration\r\n- Video adapter configuration\r\n- Serial ports information\r\n- CPU information for each processor\r\n- Disk drives information\r\n- Physical memory information\r\n- User accounts\r\n- Daylight Saving Time\r\n- Kill the specified program\r\n- Logoff current user on any WMI enabled computer\r\n- Ethernet adapters' link speed\r\n- List printers with status and number of printjobs, or pause or resume printing on the specified printer(s), or flush all printjobs, or list all printers, their status and number of printjobs\r\n- Windows Registry\r\n- Reboot/Shut down any WMI enabled computer on the network\r\n- Services\r\n- Startup commands (Startup folder and registry Run)\r\n- Synchronize your computer's system time with any webserver\r\n- Uptime for any WMI enabled computer\r\n- and many others\r\n\r\nWith Active Scripting any of above task is just few lines of code. For example, all disk drives information:\r\n\r\n\u003e             wmi.Connect()\r\n\u003e             wmi.ExecQuery('Select * from Win32_DiskDrive')\r\n\u003e             \r\n\u003e             LOOP i=1 TO wmi.items.Count()\r\n\u003e               CLEAR(DriveQ)\r\n\u003e               DriveQ:Caption           = wmi.items.GetProp(i, 'Caption')\r\n\u003e               DriveQ:Description       = wmi.items.GetProp(i, 'Description')\r\n\u003e               DriveQ:Manufacturer      = wmi.items.GetProp(i, 'Manufacturer')\r\n\u003e               DriveQ:Model             = wmi.items.GetProp(i, 'Model')\r\n\u003e               DriveQ:Name              = wmi.items.GetProp(i, 'Name')\r\n\u003e               DriveQ:Partitions        = wmi.items.GetProp(i, 'Partitions')\r\n\u003e               DriveQ:Size              = wmi.items.GetProp(i, 'Size')\r\n\u003e               DriveQ:Status            = wmi.items.GetProp(i, 'Status')\r\n\u003e               DriveQ:SystemName        = wmi.items.GetProp(i, 'SystemName')\r\n\u003e               DriveQ:TotalCylinders    = wmi.items.GetProp(i, 'TotalCylinders')\r\n\u003e               DriveQ:TotalHeads        = wmi.items.GetProp(i, 'TotalHeads')\r\n\u003e               DriveQ:TotalSectors      = wmi.items.GetProp(i, 'TotalSectors')\r\n\u003e               DriveQ:TotalTracks       = wmi.items.GetProp(i, 'TotalTracks')\r\n\u003e               DriveQ:TracksPerCylinder = wmi.items.GetProp(i, 'TracksPerCylinder')\r\n\u003e               ADD(DriveQ)\r\n\u003e             END\r\n\r\nHow to terminate running process:\r\n\r\n\u003e             wmi.Connect()\r\n\u003e             !- find all processes with specific caption\r\n\u003e             wmi.ExecQuery(printf('Select * from Win32_Process WHERE Caption=%S', pProcess))\r\n\u003e       \r\n\u003e             !- terminate each process\r\n\u003e             LOOP i=1 TO wmi.items.Count()\r\n\u003e               wmi.items.CallMethod(i, 'Terminate')\r\n\u003e             END\r\n\r\nHow to reboot specific computer:\r\n\r\n\u003e             !- required \"Shutdown\" privelege\r\n\u003e             wmi.Connect(pMachineName, 'Shutdown')\r\n\u003e       \r\n\u003e             !- find primary OS\r\n\u003e             wmi.ExecQuery('SELECT * FROM Win32_OperatingSystem WHERE Primary=True')\r\n\u003e       \r\n\u003e             !- reboot\r\n\u003e             wmi.items.CallMethod(1, 'Reboot()')\r\n\u003e             IF wmi.ErrNumber()\r\n\u003e               MESSAGE(wmi.ErrDescription())\r\n\u003e             END\r\n\r\nQuerying the amount of memory a particular process uses:\r\n\r\n\u003e             wmi.Connect()\r\n\u003e             wmi.ExecQuery(printf('SELECT * FROM Win32_Process WHERE Name = %S', pProcess))\r\n\u003e             LOOP i=1 TO wmi.items.Count()\r\n\u003e               CLEAR(MemQ)\r\n\u003e               MemQ:Amount = wmi.items.GetProp(1, 'WorkingSetSize')\r\n\u003e               ADD(MemQ)\r\n\u003e             END\r\n\r\n#### Practical use of Active Scripting: [Windows Search](https://docs.microsoft.com/ru-ru/windows/win32/search/-search-3x-wds-overview?redirectedfrom=MSDN)\r\n\r\nWindows Search is a desktop search platform that has instant search capabilities for most common file types and data types.\r\n\r\nLet’s look at some examples.\r\n\r\n**Search by file name**\r\nTo find all “setup.exe” files you define “System.FileName=‘setup.exe’” condition:\r\n\r\n\u003e               ws.Search('SELECT System.ItemPathDisplay FROM SystemIndex WHERE System.FileName=''setup.exe''')\r\n\u003e               LOOP UNTIL ws.EOF()\r\n\u003e                 CLEAR(FilesQ)\r\n\u003e                 FilesQ:Name = ws.rs.Field('System.ItemPathDisplay')\r\n\u003e                 ADD(FilesQ)\r\n\u003e                 ws.MoveNext()\r\n\u003e               END\r\n\r\nTo perform a search by mask (“setup.*”) use ‘LIKE’ operator:\r\n\r\n\u003e               ws.Search('SELECT System.ItemPathDisplay FROM SystemIndex WHERE System.FileName LIKE ''setup.*''')\r\n\r\n**Search by file content**\r\nYou can search for words and phrases, below “FREETEXT” predicate is used:\r\n\r\n\u003e               ws.Search('SELECT System.ItemPathDisplay FROM SystemIndex WHERE FREETEXT(''Windows Search'')')\r\n\r\n**Search by document type**\r\nNext example finds all big pictures (image size is greater than 1024x768):\r\n\r\n\u003e               ws.Search('SELECT System.ItemPathDisplay FROM SystemIndex WHERE System.Kind = ''Picture'' AND System.Image.VerticalSize \u003e= 768 AND System.Image.HorizontalSize \u003e= 1024')\r\n\r\nYou can request not only System.ItemPathDisplay (which actually is full filename), but any type of information: size, modified date, author, image width, color depth and so on.\r\n\r\nWindows Search allows requests against remote machine as well, all you need is machine name:\r\n\u003e               SELECT System.ItemPathDisplay FROM MACHINENAME.SystemIndex\r\n\r\nYou can add folders to Search Index using [this project](https://github.com/mikeduglas/Search-API).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeduglas%2Factivescripting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikeduglas%2Factivescripting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeduglas%2Factivescripting/lists"}