On 07.01.2022 16:16, Bob Bridges wrote: > When I first started learning ooREXX (not that long ago, and I still don't > know it well) I read that bit about "messages" that are apparently sent to > methods and properties and was confused. My only object-oriented language at > the time was VB (the VBA and VBS varieties), and I thought of methods as > merely specialized function calls. > > Really I still do, I guess. I told myself provisionally that the tilde in > ooREXX is simply the equivalent of the period in a VBA method or property > reference, and although I'm pretty sure that isn't the whole story I was at > least able to continue on that basis. I keep reading descriptions like the > below, though, thinking that more will sink in eventually.
That is a great stance! :) When teaching ooRexx (the course is called "Business Programming"), in the middle of the semester (after two months, 4 hours per week) the students arrive at writing ooRexx programs against Windows and MS Office. They will propose three little projects (controlling three Windows applications, one must not be from Microsoft, from a single ooRexx script that creates value, solves a specific problem) of which one gets picked which they need to implement within a week and present it. Now, newcomers who have never been exposed to programming and those who learned some programming already usually have never worked with OLE and scripting Windows applications via OLE. OTOH in the Windows world VBA is known, popular because of MS Office and those application for which VBA got licensed from MS. Given the huge market share for so many years there are incredibly many VBA code snippets that demonstrate how to achieve some given functionality using VBA, such that by studying the VBA code helps one to find the needed solution path rather quickly (which values/objects need to be fetched, which attributes and method routines with what arguments etc. are needed and so on). Also, they learn that for Windows applications that have VBA as a macro language, they can usually employ some function "record macro" which will record all user generated events (key presses, clicks, selections, etc.) and translate them into the respective VBA macro program when exercising a matching "saving macro". One can then study the resulting VBA macro program to see what objects need to be addressed how, which methods/functions need to be invoked in which sequence with what arguments, etc. --- The challenge then is: how to translate VBA code to ooRexx? And indeed, the simplest advice is to change the VBA dot (.) to the ooRexx tilde (~), which in 90% of the cases is already everything one needs to know! The VBA dot (.) operator works like the C++ dot operator (e.g. <https://www.ibm.com/docs/en/zos/2.4.0?topic=expressions-dot-operator>), it allows one to define a path (path segments concatenated by dots) to the embedded member of a structure, which can be a an attribute/field/property, a method routine... The ooRexx tilde (~) operator is the message operator. Replacing the VBA dot with the ooRexx message operator causes the fetching of the referred to element by fetching each path segment one by the other and in the end referring to the member. In another post I mentioned that I had employed VBA in the past to teach Business administration students how to automate and program (confined to the Windows world back then), that VBA is rather difficult to teach despite carrying the name "BASIC" in its name. Some of the reasons are quite a few idiosyncracies that need far too much explanation (i.e. too much time) such that at the end of the course there was no time left for learning more about exploiting/applying the learned concepts. Therefore I created a little presentation that documents the most important VBA features the students would be confronted with (e.g. with VBA macro code from "record macro") and how they translate to ooRexx (the students had learned REXX and ooRexx by then, i.e. in addition to the BIFs the additional message paradigm which is available in all contexts). The same rules apply also the other way around, i.e. in translating ooRexx code to VBA code in a Windows environment. Here the link to these slides: <http://wi.wu.ac.at/rgf/wu/lehre/autowin/material/foils/AutoWin_04.pdf>, cf. slides # 2 thru # 8 (slide # 8 also demonstrates the different possibilities one can exploit in invoking routines in VBA). Quite important to know are two things when mapping VBA code to ooRexx code: * If a VBA argument is of the form "somearg := abc", then a named argument is used (left of the ":=" operator is the name of the argument, right of it the value to be used for it). It may be the case that the named argument "somearg" is not defined at the given position, such that one needs to research the VBA routine/function definition and locate the position of the argument named "somearg". Then in the ooRexx version one needs to place "somearg" at that very position (if there are omitted arguments before it, one would need to prepend commas to indicate them). * If a VBA program uses constants from a Windows application, the IDE allows for using the constant name as an argument and will replace it transparently with the constant value when using it. In ooRexx would you need to fetch the constant's value (using the "getConstant(name)" message) and then supply that returned value. It is interesting that with this knowledge all the students have been able to research the Internet for the OLE interfaces to the Windows applications that they exploit from ooRexx, in the course locating VBA code snippets and successfully translating them to ooRexx! If you were to look into the Windows version of ooRexx, you would get a REXX++ ;) interpreter and apply this knowledge to your own Windows applications, if you see a need to program them from ooRexx. To check that out, just look into the subdirectories named "samples" and "samples\ole" and its subdirectories which among other things demonstrate how to use Excel, if you still have it, Lotus 123 ;), Notes, but also Active Directory service interfaces (ADSI) [1], WMI (Windows management instrumentation) [2] which would give you an impression what has become possible with the Windows version of ooRexx [3]. It may be fun exploring what ooRexx brings new to the REXX table, and it is quite likely that it proofs to be beneficial! You will see what a great productivity tool it is, still easy to use and easy to exploit! ---rony [1] e.g. MS intro to ADSI: <https://docs.microsoft.com/en-us/windows/win32/adsi/active-directory-service-interfaces-adsi> [2] e.g. MS intro to WMI: <https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page> [3] latest ooRexx 5 installation packages: <https://sourceforge.net/projects/oorexx/files/oorexx/5.0.0beta/> ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
