Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Jan-Erik Lärka

Pages: [1] 2 3
1
Programming / ooRexx to control GhostScript
« on: October 14, 2024, 06:37:59 pm »
Hello,

here's a "library" and the script (rename pdf.txt to pdf.cls and TestPDFLib.txt to TestPDFLib.rex ) to use it.
The script should run on win, *nix and os2, but seem to fail on the latter for some functionality.

Note that you may have to tweak ooRexx rexxsetenv.cmd to even be able to access GhostScript.
Run with:
Code: [Select]
rexx TestPDFLib
One can of course write code to do these things in classic rexx, object rexx and plain command line as well,
but the interesting part here is that it should be reusable (not possible with classic rexx).
With some adjustment it should work with Object Rexx as well.

It can be used to merge separate PDF-files, but example of that is not included.


2
Programming / Classic, Regina, Object and Open Object Rexx
« on: October 01, 2024, 06:58:57 pm »
I see that the knowledge of REXX is somewhat limited even with OS/2 users.

Classic Rexx (by IBM) is the default scripting language in OS/2, eComStation and ArcaOS and one just need a simple text editor and write in fairly plain English.
It allow you as a user to write scripts to aid you with certain tasks and it is well integrated with the system so that you don't need to specify an executable to run a script, but it also drive applications as the "engine" written with for example DrDialog, VX-REXX and even code you can write yourself and compile.
It is not possible to create reusable text libraries of code to just call, but one can write functions in the script that perform certain tasks. It's is however possible to use external compiled libraries.

Regina Rexx (by Mark Hessling) is more modern, very similar to Classic Rexx, but lack the system integration.
It is more up to date than Classic Rexx and probably also somewhat more reliable.

Object Rexx (by IBM) addressed some of the shortcomings of Classic Rexx, and on can switch to it in OS/2, eComStation and ArcaOS, while the way to write code also evolved and introduced ~ and arrays with [] but also external reusable code libraries, written in plain text Object Rexx.
Object Rexx is just as well integrated with the base OS as Classic Rexx, can run and use Classic Rexx scripts end external compiled libraries and be the engine for DrDialog, VX-REXX etc., but was never set as default due to that the OS/2 version had some flaws caused by the compiler used, if I remember correctly.

Open Object Rexx (by RexxLA)
has refined what IBM created with Object Rexx and also cleaned up some syntax and introduced a lot of useful and powerful stuff. We now have an up to date and current ooRexx back ported to OS/2 but the integration found in Classic Rexx and Object Rexx is missing so DrDialog, VX-REXX etc. can not benefit from the new features, easier and simpler way to express complicated information and relations etc. but still need to rely on those old scripting engines to be present. If we'd have the intergration Classic Rexx and Object Rexx could be phased out in favor of the new and open version. What we need is what I express as the integration part and that it can run in any command line environment, not only 4OS2.

So what can one do with REXX you wonder?
Alex Taylor has for example written some excellent software that you may have used, both command line scripts and GUI applications like Naps and ANPM to mention a few.
Glassman wrote AutoWGet that is very helpful to fetch things from the internet
and much more...

I use ooRexx to automatically create documents with maps to send to owners of land at work, drive office applications, vector drawing applications such as OpenOffice Draw, Calc etc. split/merge/extract text PDF documents with GhostScript and retrieve routes from google between places etc.

I would like to get your attention to push for an update to the wps integration stuff and enable it for ooRexx on OS/2, without reinventing the wheel from scratch.
The problem is that IBM have a cross licensing agreement with another party (Amiga)?!

3
Setup & Installation / How to? python, pip and language tool
« on: June 11, 2024, 08:28:55 pm »
i have a need to run something that can translate text and the tools provided now all seem to use python and require pip etc.

One can use a standard OS/2 command prompt an run the command as Python 3.7 and onward comes with an ensurepip module.
python -m ensurepip --upgrade
it seem to install version 23, but another run, upgrade it to version 24.

Am aware that it may not know how to handle ArcaOS and OS/2, but it may be possible to iron out some things.

How can one install a downloadable AI tool, translation tool etc. ?
I wouldn't mind a tool to just select what to install.

Example of google translator, but the others seem to have similar issues as seen below.

[C:\usr\lib\python3.9\site-packages]python pip install googletrans
WARNING: The directory 'd:/home/.cache/pip' or its parent directory is not owned
 or is not writable by the current user. The cache has been disabled. Check the
permissions and owner of that directory. If executing pip with sudo, you should
use sudo's -H flag.

Collecting googletrans
  Downloading googletrans-3.0.0.tar.gz (17 kB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  pip subprocess to install build dependencies did not run successfully.
  exit code: 2

  [1 lines of output]
  C:\USR\BIN/python.exe: can't open file 'C:/usr/lib/python3.9/site-packages/C:/
usr/lib/python3.9/site-packages/pip': [Errno 2] No such file or directory
  [end of output]

 note: This error originates from a subprocess, and is likely not a problem wit
h pip.
error: subprocess-exited-with-error

pip subprocess to install build dependencies did not run successfully.
exit code: 2

See above for output.

note: This error originates from a subprocess, and is likely not a problem with
pip.

//Jan-Erik

4
Applications / A thought remote 2 local
« on: May 26, 2024, 09:37:41 am »
I would like to discuss something I've thought about for some time.
Do try to keep an open mind as you read it, with portions/combinations of virutal machine, rdp, citrix, odin, compiler, pathremapper etc.

Imagine that we have an OS but yet no current major applications for it.

If we could get one application that run "remotely" or in a virtual environment on another os, that would in the initial release send over bitmaps of the applicaiton window.
On the client side (on our OS) we would have an application that draw the application window on our desktop.
The client handle clipboard, send mouse and keyboard input to the server that start and run the application.
Nothing fancy, this is basiclly VNC today, but without a fully visible desktop.

The next release of the server would send over the resources (dialogs, bitmaps/images etc.)
The next release of the local client use local look and feel for those resources when applicable.

The server should then in small steps take over and act as sandbox to the application on the server.
Send drawing commands through the server instead of capturing images of the window. The server need to return that the drawing operation as "completed successfully" right away to not stall execution, while transferring the information to the client, thus use some asyncronious mechanism.
The client should take over drawing as much as possible.

The server determine portions of the execution that doesn't rely on external libraries (dll:s and system calls) as those should be possible to hand over to the client to store as executable code.

The server determine portions of the execution that rely on system calls and hand those over to the client to call versions available on our OS, compile locally and store as executable code.

I guess that the trickier parts emerge at this point, as the server handle external libraries that depend on each other and recreate/interpret (a 64-bit like odin) send it over to compile locally to our client OS and save as library.

Depending on the server OS, hard coded system paths and delimiters ( / instead of our \ ) may need special attention or subsystem support to not cause headache.

This is also the point when simple applications should be able to run on their on, locally on our until now "client" OS, without server and thus no longar as "client". The more libraries that can be translated the more applications will run, but the hateful exact version numbering problem that seem to be in fashion instead of "improve what you got" may be difficult to overcome.

Someone may have to buy portions of tech from IBM or ... to be able to accelerate hardware graphics.

5
Programming / Rexx dll for UniAud
« on: December 27, 2023, 12:09:49 pm »
Hello,

Here's a library to be used with rexx, designed to have the functionality of unimix.exe
The included script demonstrate what it can do, read it to see what it does.
The script doesn't contain an interactive mode as later versions of unimix do, but instead use a stem array to list and set values that you should find useful.

Use and test the script and library at your own risk, it is provided "AS IS". It is your own fault if you break something with it!

No further documentation, information or source code about the library is included in this package.

I do invite you to improve it! :)

Regards,
//Jan-Erik

6
Applications / 3D solid modelling in OS/2 with Irit and GuiIrit
« on: August 07, 2023, 08:48:05 am »
The only 3D solid modelling tool I've found for OS/2 is Irit V7.0, but I've actually never seen it in action and can't figure out how to make it show something. Input seem text based and I'm used to the point and click of Solid Edge v7 (ca. 1999) to design things.

Did however look at it at the Irit home page this weekend and the documentation mention OS/2 in various places for the current version (v12).

There's also a GUI for it (GUIrit) that use wxWindows. The installer for the win binary specifically mention OS/2!
Anyone got a built copy for OS/2 to spare?

Ohh, btw Sweet Home 3D version 7.1 can be used in 2D mode with OS/2 java 1.6 even though the web page mention that it need newer versions of java.

7
Applications / Apache OpenOffice Base
« on: April 16, 2023, 07:45:06 am »
Hi,

I have a need to use OpenOffice Base on ArcaOS-OS/2 and have now tried it over and over again in several versions over the years...
One can create a new connection, jdbc with OpenJDK 1.6 as well, add tables, use the wizards, create reports with Oracle Report Builder as well.
The problem start as one reopen the saved .odb file, I guess from all retries with different database engines* I've done, that it may skip over some initialiation routine and thus fail (bail out/abort) as it behave ok at first.

What can one do to overcome this?

PostgreSQL
MySQL
hsqldb (both emedded with OpenOffice and as stand alone server)
Derby
dbf
spreadsheet
etc.

Code: [Select]
   EBP     Address    Module     Obj:Offset    Nearest Public Symbol
 --------  ---------  --------  -------------  -----------------------
 Trap  ->  1F47D03E   LIBCN0    0001:000FD03E

 0012FA58  1F47D80A   LIBCN0    0001:000FD80A

 0012FA78  1F3DAC85   LIBCN0    0001:0005AC85

8
Multimedia / Mic/Line in with UniAud (3.0.1)
« on: January 16, 2022, 09:26:02 pm »
Hi,

The new build(s) of UniAud show more and more of the built in sound card (ATI HDA, ALC888) functionality with unimix.
I'd like to use the now enabled/recognized Mic in and/or Line in, but "Digital Audio" recorder and the os2tk45 "Audio Recorder Sample" and "Direct Audio" samples either stall the computer or the application. VoiceType therefore can't enable input.

Are there something to do?

Regards,
//Jan-Erik

9
Programming / redirect stdout, stderr and stdin
« on: July 28, 2021, 09:31:41 pm »
Hello,

would like to run one vio application at the time in a separate thread and redirect stdout, stderr and stdin to control it. Tried variations to the example found in "IBM Developers Toolkit version 4.5", "Control Program Programming Giude and Reference", "Redirecting Standard I/O for Child Processes".

The example only describe how to do it for stdout, but I've found examples that include stderr or stdin, but not quite the way intended here.

sqlite3.exe would be a great example.
One can start it and enter a command, wait for the output and then enter a new command (sql query) and continue, and not just a command at startup.

One would be able to write the support library required for oosqlite and Open Object Rexx 5.0.0 on OS/2-ArcaOS.  ;)

See attachment... Please do tell how it should be written instead.

//Jan-Erik

10
Setup & Installation / JRUN - Looking for Guinea pig(s)
« on: January 11, 2021, 03:12:28 pm »
Hello,

I'd like to ask you for help to test a rather advanced script I've created to aid launch of java applications.
The goal is to make it as easy to install a java app as click on a .jar/.class file.

The script can use OpenJDK 6 and Java 4 in parallel. (See README)

Please do tell me what alterations/adjustments and additions you make to the script as well as faults and problems.

Regards,
//Jan-Erik

Remember: If something goes wrong, it's your fault!

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

11
Programming / Android SDK with classic rexx
« on: September 16, 2019, 11:23:07 pm »
This is a script that create a program object that you can use to list and download Android SDK.
It download the current Android SDK and libraries as I write this.
Prerequisite: java and android-sdk_r24.4.1-windows.zip (as previously found through) unpacked to a folder
  • Just run the script by double clicking on it.
  • It search your computer for the unpacked sdk, copy itself and files it need and create a program object (if possible).
  • Double click on the program object and type "update sdk --filter 3,2,1" and follow the instructions.
    repeat the procedure with the packages you want to download, use "list sdk" to list available packages.
The script add "--no-ui --no-https" as it doesn't work otherwise.
Please also note that I don't know if you can actually develop something with the downloaded files, that is up to you to find out.
It was intended to act as a subsystem for development with NetRexx to create apps for Android, but I didn't persue it further since there are so few examples and information on how to actually code NetRexx apps and deploy them on Android.
Code: [Select]
/*
 * Filename: android.cmd
 *   Author: JanErik
 *  Created: Sun Sep 11 2016
 *  Purpose: Install SDK for Android in OS/2
 *  Changes: Mon Sep 16 2019 Changes to program object and startup configuration.
 *  Require: Zip SDK (such as android-sdk_r24.4.1-windows.zip), downloads updates live.
 */

'@echo off'
'@mode 80,102'
'@cls'

/* Set up prog to be the path of this script, including following symlinks,
   and set up progdir to be the fully-qualified pathname of its directory. */
PARSE SOURCE . . prog
PARSE ARG params

IF LENGTH( STRIP( params ) ) = 0 THEN
   params = '-h'

/* Grab current directory before we change it */
work_dir = DIRECTORY()

/* Change current directory and drive to where the script is, to avoid
 issues with directories containing whitespaces. */
PARSE VALUE REVERSE( prog ) WITH fname'\'this
this = REVERSE( this )
CALL DIRECTORY this

/* Load RexxUtil Library */
IF RxFuncQuery('SysLoadFuncs') THEN
DO
   CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
   CALL SysLoadFuncs
END

env = 'ENVIRONMENT'
/* Check we have a valid Java.exe in the path.*/
IF VALUE( 'JAVA_HOME',, env ) = '' THEN
DO
   CALL SysGetEA this, 'JAVA_HOME', 'java_path'
   IF STREAM( java_path'\JAVA.EXE', 'C', 'QUERY EXISTS' ) = "" THEN
      java_path = ''
   IF LENGTH( java_path ) < 2 THEN DO
      PARSE UPPER VALUE rxFind( 'JAVA.EXE', ' -version', 'VERSION "1.' ) WITH java_path'\BIN'
      IF LENGTH( java_path ) = 0 THEN
      DO
         CALL LINEOUT 'STDERR', 'JAVA engine not found'
         RETURN 1
      END
      CALL SysPutEA this, 'JAVA_HOME', java_path
   END
END
ELSE java_path = VALUE( 'JAVA_HOME',, env )

CALL SysGetEA this, 'ANDROID_PATH', 'android_path'
IF STREAM( android_path'\android.bat', 'C', 'QUERY EXISTS' ) = "" THEN
   android_path = ''
IF LENGTH( android_path ) < 2 THEN DO
   PARSE VALUE rxFind( 'android.bat' ) WITH android_path
   IF LENGTH( android_path ) = 0 THEN
   DO
      CALL LINEOUT 'STDERR', 'Android SDK not found'
      RETURN 2
   END
   CALL SysPutEA this, 'ANDROID_PATH', android_path
END
ext = 'cmd ico png'
DO i = 1 TO 3
   IF STREAM( android_path'\android.'SUBWORD( ext, i, 1 ), 'C', 'QUERY EXISTS' ) = '' THEN
      IF SysCopyObject( this'\android.'SUBWORD( ext, i, 1 ), android_path ) = 1 THEN
         CALL LINEOUT 'STDERR', 'Copied android.'SUBWORD( ext, i, 1 )' to "'android_path'"'
END
IF TRANSLATE( android_path ) <> TRANSLATE( this ) THEN
DO
   this = android_path
   work_dir = android_path
END

objID = 'ANDROID'
android_name = 'Android'
android_wps = 'Android SDK'
IF wpsObjectExist( '<WP_'objID'>' ) = 0 THEN
DO
   setupstring = 'OBJECTID=<WP_'objID'>;NOAUTOCLOSE=YES;EXENAME='this'\android.cmd;PARAMETERS=[Specify parameter (list sdk --filter 1)];ICONFILE='this'\'android_name'.ico;'
   IF SysCreateObject( 'WPProgram', android_wps, '<WP_DEVFLDR>', setupstring, 'U' ) <> 1 THEN
      CALL SysCreateObject 'WPProgram', android_wps, '<WP_DESKTOP>', setupstring, 'U'
   CALL rxAddBigIcon this'\'android_name'.png', '<WP_'objID'>'
END

jar_path = 'lib\sdkmanager.jar;lib\swtmenubar.jar'

/* Set SWT.Jar path based on current architecture (x86 or x86_64)*/
CALL DIRECTORY this
swt_path = ''
DO WHILE LENGTH( swt_path ) = 0
   DO WHILE QUEUED() > 0; PARSE PULL; END
   '@'java_path'\bin\java.exe -jar lib\archquery.jar|rxqueue'
   PARSE PULL swt_path
END

MkTempCopy:
    /* Copy android.bat and its required libs to a temp dir.
       This avoids locking the tool dir in case the user is trying to update it.*/

   tmp_dir = VALUE( 'TEMP',,'ENVIRONMENT' )'\temp-android-tool'
   cpy = swt_path'\* common.jar commons-codec* commons-compress* commons-logging dvlib.jag gson* guava* httpclient* httpcore* httpmime* layoutlib-api.jar org-eclipse-* sdk* swtmenubar.jar'
   DO i = 1 TO WORDS( cpy )
      cpyfile = 'lib\'SUBWORD( cpy, i, 1 )
      IF POS( '*', cpyfile ) > 0 THEN
      DO
         CALL SysFileTree this'\'cpyfile, 'file.', 'SFO'
         DO j = 1 TO file.0
            CALL rxCpyFile this, file.j, tmp_dir
         END
      END
      ELSE CALL rxCpyFile this, this'\'cpyfile, tmp_dir
   END

   /* jar_path and swt_path are relative to PWD so we don't need to adjust them, just change dirs.*/
   tools_dir = android_path
   CALL DIRECTORY tmp_dir

EndTempCopy:

   /* The global ANDROID_SWT always override the SWT.Jar path */
   IF VALUE( 'ANDROID_SWT',,'ENVIRONMENT' ) <> '' THEN
      swt_path = VALUE( 'ANDROID_SWT',,'ENVIRONMENT' )
   ELSE
      swt_path = this'\lib\'swt_path
   IF DIRECTORY( swt_path ) = '' THEN
   DO
      CALL LINEOUT 'STDERR', 'ERROR: SWT folder "'swt_path'" does not exist.'
      CALL LINEOUT 'STDERR', 'Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.'
      RETURN 2
   END

SetPath:
/* Finally exec the java program and end here.
 REMOTE_DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000*/
   IF 0 = POS( TRANSLATE( java_path ), TRANSLATE( VALUE( 'PATH',,'ENVIRONMENT' ) ) ) THEN
      CALL VALUE 'PATH', java_path'\bin;'||STRIP( VALUE( 'PATH',,'ENVIRONMENT' ),, ';' ), 'ENVIRONMENT'
   IF 0 = POS( TRANSLATE( tools_path ), TRANSLATE( VALUE( 'PATH',,'ENVIRONMENT' ) ) ) THEN
      CALL VALUE 'PATH', tools_path'\lib;'||STRIP( VALUE( 'PATH',,'ENVIRONMENT' ),, ';' ), 'ENVIRONMENT'
   CALL DIRECTORY tools_dir
   '@java "-Dcom.android.sdkmanager.toolsdir='tools_dir'" "-Dcom.android.sdkmanager.workdir='work_dir'" -classpath "'jar_path';'swt_path'\swt.jar" com.android.sdkmanager.Main 'params' --no-ui --no-https'
   CALL DIRECTORY work_dir
RETURN rc
   
rxCpyFile: PROCEDURE
   PARSE VALUE REVERSE( SUBSTR( ARG(2), LENGTH( ARG(1) ) + 1 ) ) WITH fname'\'fpath
   fpath = REVERSE( fpath )
   rc = rxMkDir( ARG(3)fpath )
   IF rc = 0 & STREAM( ARG(3)fpath'\'REVERSE( fname ), 'C', 'QUERY EXISTS' ) = '' THEN
      rc = SysCopyObject( ARG(2), ARG(3)fpath )
RETURN rc
   
rxChk: PROCEDURE
   DO WHILE QUEUED() > 0; PARSE PULL; END;
   '@'||ARG(1)||ARG(2)||' 2>>&1 | RXQUEUE'
   DO WHILE QUEUED() > 0
      IF POS( TRANSLATE( ARG(3) ), TRANSLATE( LINEIN( 'QUEUE:' ) ) ) > 0 THEN
         IF LENGTH( ARG(4) ) > 0 THEN RETURN ARG(4)
   END
RETURN ''
   
rxFind: PROCEDURE EXPOSE !_msg_!.
   env = 'ENVIRONMENT'
   PARSE VALUE REVERSE( SysSearchPath( 'PATH', ARG(1) ) ) WITH fname'\'fpath
   fpath = REVERSE( fpath )
   fname = REVERSE( fname )
   IF ARG() > 1 & LENGTH( fpath ) > 0 THEN
      fspec = rxChk( fpath'\'fname, ARG(2), ARG(3), fpath )
   ELSE IF STREAM( fpath'\'fname, 'C', 'QUERY EXISTS' ) <> '' THEN
      fspec = fpath
   ELSE fspec = ''
   IF LENGTH( fspec ) > 0 THEN RETURN fspec
   CALL LINEOUT 'STDERR', VALUE( 'PROGRAMS',, env )
   IF POS( '*', ARG(1) ) = 0 THEN fname = '*'ARG(1)
   ELSE fname = ARG(1)
   CALL SysFileTree VALUE( 'PROGRAMS',, env )'\'fname, 'file.', 'SFO'
   DO i = 1 TO file.0
      PARSE VALUE REVERSE( file.i ) WITH .'\'fspec
      IF ARG() > 1 THEN
         fspec = rxChk( file.i, ARG(2), ARG(3), REVERSE( fspec ) )
      ELSE
         fspec = REVERSE( fspec )
      IF LENGTH( fspec ) > 0 THEN RETURN fspec
   END
   drives = SysDriveMap( 'C:', 'USED' )
   DO j = 1 TO WORDS( drives )
      CALL LINEOUT 'STDERR', SUBWORD( drives, j, 1 )
      CALL SysFileTree SUBWORD( drives, j, 1 )||'\'fname, 'file.', 'SFO'
      DO i = 1 TO file.0
         PARSE VALUE REVERSE( file.i ) WITH .'\'fspec
         IF ARG() > 1 THEN
            fspec = rxChk( file.i, ARG(2), ARG(3), REVERSE( fspec ) )
         ELSE
            fspec = REVERSE( fspec )
         IF LENGTH( fspec ) > 0 THEN RETURN fspec
      END
   END
RETURN ''   
   
rxMkDir: PROCEDURE
    rc = ( DIRECTORY( ARG(1) ) = '' )
    IF rc = 1 THEN
        IF \rxMkDir( STRIP( FILESPEC( 'D', ARG(1) )FILESPEC( 'P', ARG(1) ), 'T', '\' ) ) THEN
           rc = SysMkDir( ARG(1) )
Return rc
   
rxAddBigIcon: PROCEDURE EXPOSE !_msg_!. java_path
    crlf = D2C(13)D2C(10)
    bigicons_dir = VALUE( 'BIGICONS',, 'ENVIRONMENT' )
    bigicon = FILESPEC( 'N', ARG(1) )
    objid = ARG(2)
    IF LENGTH( bigicons_dir ) > 0 THEN
    DO
        IF STREAM( ( bigicons_dir'\'bigicon ), 'C','QUERY EXISTS') = '' THEN
           IF SysCopyObject( ARG(1), bigicons_dir ) = 0 THEN
              RETURN 1
        IF STREAM( bigicons_dir'\bigicons.txt', 'C', 'QUERY EXIST' ) <> '' THEN
        DO
            f_size = STREAM( bigicons_dir'\bigicons.txt', 'C', 'QUERY SIZE' )
            IF f_size > 0 THEN
            DO
                input = CHARIN( bigicons_dir'\bigicons.txt', 1, f_size )
                CALL STREAM bigicons_dir'\bigicons.txt', 'C', 'CLOSE'
                PARSE UPPER VALUE input WITH pre'"'(bigicon)'"'post
                IF LENGTH( post ) > 0 THEN RETURN 2
                PARSE UPPER VALUE input WITH pre'"'(objid)'"'post
                IF LENGTH( post ) > 0 THEN RETURN 3
                PARSE VALUE input WITH pre'[OBJECTID]'mid(crlf)(crlf)'['post
                input = pre'[OBJECTID]'STRIP( STRIP( mid, 'T', D2C(10) ), 'T', D2C(13) )||crlf||LEFT( '"'objid'"', 28 )'"'bigicon'"'crlf||crlf'['post
                CALL SysFileDelete bigicons_dir'\bigicons.txt'
                CALL CHAROUT bigicons_dir'\bigicons.txt', input
                CALL STREAM bigicons_dir'\bigicons.txt', 'C', 'CLOSE'
            END
            ELSE RETURN 4
        END
    END
RETURN 0

/* Code borrowed from REXX Tips & Tricks v3.60 */
wpsObjectExist: PROCEDURE /* parameter: '<new_wps_object_id>', return: 1 exist, 0 doesn't exist, 43 error */
  PARSE ARG objID
  rc = 43               /* init return/error code 43 = routine not found */
  SIGNAL ON SYNTAX NAME ObjectExistError

  IF SUBSTR( objID, 2, 1 ) <> ":" THEN
      IF LEFT( objID, 1 ) <> "<" & RIGHT( objID, 1 ) <> ">" THEN
          objID = "<" || objID || ">"

  /* create the object and see if it fail */
  tempRC = SysCreateObject( "WPFolder", "TestObject", "<WP_NOWHERE>", "OBJECTID=" || objID || ";", "FAIL" )

  IF tempRC = 1 THEN
  DO
    CALL SysDestroyObject objID
    rc = 0
  END
  ELSE
    rc = 1

ObjectExistError:

RETURN rc

12
Programming / Mac Address in Classic Rexx
« on: September 15, 2019, 07:43:43 am »
This code can list all my machines on the network (and send a wake upp call if they listen).
It doesn't however give me the hostname of the router/dhcp-server. Ideas how to?
 
Code: [Select]
/*
 * Filename: macaddr.cmd
 *   Author: JAN-ERIK
 *  Created: Mon Sep 10 2012
 *  Purpose: Retrieve MAC Address
 *  Changes: 2019-07-25, Added support for Router
 *           2019-09-14, Updated support for localhost
 *           2019-09-15, OS2ENVIRONMENT -> ENVIRONMENT
 */
stem = 'host.'
IF 0 < ARG() THEN
   count = rxGetMacAddr( ARG(1) )
ELSE
   count = rxGetMacAddr()
DO i = 1 TO count
    /*magic.cmd*/
    /*Wake on Lan in REXX*/
    /*MAC = '11:22:33:44:55:66';*/
    MAC = host.i.macaddr
    SAY host.i.name||':' host.i.ipaddr||':' MAC;
    X = TRANSLATE( 'abcdefghijkl', host.i.macaddr, 'ab:cd:ef:gh:ij:kl' )
    call RxFuncAdd 'SockLoadFuncs', 'rxsock', 'SockLoadFuncs';
    call SockLoadFuncs( '*' );
    SCT = SockSocket( 'AF_INET', 'SOCK_DGRAM', 'IPPROTO_UDP' );
    RC = SockSetSockOpt( SCT, 'SOL_SOCKET', 'SO_BROADCAST', '1' );
    RC = SockIOCtl( SCT, 'FIONBIO', '0' );
    adr.!family = 'AF_INET';
    /*adr.!addr   = '255.255.255.255';*/
    adr.!addr   = host.i.ipaddr
    adr.!port   = 9;
    S = COPIES( D2C(255) ,6 );
    T = COPIES( X ,16);
    G = COPIES( D2C(0) ,6 );
    RC = SockConnect( SCT, "adr.!" );
    STG = S||T||G;
    SAY STG
    RC = SockSend( SCT, STG );
    call SockSoClose SCT;
END
RETURN 0

rxGetMacAddr: PROCEDURE EXPOSE (stem) /*<COMPUTERNAME>*/
    isStem = ( RIGHT( stem, 1 )  = '.' )
    stemval = STRIP( stem, 'T', '.' )
    retval = 0
    i = 1
    /* No parameters given, list all computers */
    IF ARG() = 0 THEN
    DO
        DO WHILE QUEUED() > 0; PARSE PULL; END;
        /* Computers on network */
        '@NET VIEW 2>&1|RXQUEUE'
        DO WHILE QUEUED() > 0
            PARSE UPPER VALUE LINEIN( 'QUEUE:' ) WITH '\\'computer.i' '.
            /* Add computer to list */
            IF LENGTH( computer.i ) > 0 THEN i = i + 1
        END
        computer.0 = i - 1
    END
    ELSE DO
        /* Search for a specific computer */
        computer.0 = 1
        computer.1 = TRANSLATE( ARG(1) )
    END
    j = 0
    DO WHILE QUEUED() > 0; PARSE PULL; END;
    DO i = 1 TO computer.0
       IF computer.i = VALUE( 'HOSTNAME',, 'ENVIRONMENT' ) THEN
       DO
          '@NETSTAT -a 2>&1|RXQUEUE'
          DO WHILE QUEUED() > 0
             PARSE UPPER VALUE LINEIN( 'QUEUE:' ) WITH 'ADDR 'ipnum' INTERFACE' .
             ipnum = STRIP( ipnum )
             IF ipnum <> '127.0.0.1' & ipnum <> '0.0.0.0' & ipnum <> '' THEN
                LEAVE
          END
          DO WHILE QUEUED() > 0; PARSE PULL; END;
          '@NETSTAT -n 2>&1|RXQUEUE'
          DO WHILE QUEUED() > 0
             PARSE UPPER VALUE LINEIN( 'QUEUE:' ) WITH 'PHYSICAL ADDRESS' machex 'MTU' .
             machex = STRIP( machex )
             IF machex <> 0 & LENGTH( machex ) = 12 & LENGTH( ipnum ) > 7 THEN
             DO
                j = j + 1
                machex = TRANSLATE( 'ab:cd:ef:gh:ij:kl', machex, 'abcdefghijkl', ':' )
                IF isStem THEN
                   INTERPRET stemval'.j.name = computer.i;'||stemval'.j.macaddr = TRANSLATE( machex, "0", " " );'||stemval'.j.ipaddr = ipnum;'||stemval'.0 = j; retval = j'
                ELSE
                   retval = retval||computer.i||' '||TRANSLATE( machex, "0", " " )||' '||ipnum||D2C(13)||D2C(10)
             END
          END
       END
       ELSE DO
          '@PING '||TRANSLATE( computer.i )||' 1 1 2>&1|RXQUEUE'
          DO WHILE QUEUED() > 0; PARSE PULL; END;
          '@ARP '||TRANSLATE( computer.i )||' 2>&1|RXQUEUE'
          DO WHILE QUEUED() > 0
             PARSE UPPER VALUE SUBWORD( LINEIN( 'QUEUE:' ), 2 ) WITH machex +17 ipnum .
             IF LENGTH( machex ) = 17 & LENGTH( ipnum ) > 7 THEN
             DO
                j = j + 1
                IF isStem THEN
                   INTERPRET stemval'.j.name = computer.i;'||stemval'.j.macaddr = TRANSLATE( machex, "0", " " );'||stemval'.j.ipaddr = ipnum;'||stemval'.0 = j; retval = j'
                ELSE
                   retval = retval||computer.i||' '||TRANSLATE( machex, "0", " " )||' '||ipnum||D2C(13)||D2C(10)
             END
          END
       END
    END
    IF 1 < computer.0 THEN
    DO
        DO WHILE QUEUED() > 0; PARSE PULL; END;
        '@ARP -a 2>&1|RXQUEUE'
        DO WHILE QUEUED() > 0
           arp = LINEIN( 'QUEUE:' )
           IF 0 < POS( ':', arp ) & 3 < WORDS( arp ) THEN
           DO
              PARSE UPPER VALUE arp WITH iface +13 macad +17 ipadd rest
              DO i = 1 To VALUE( stemval'.0' )
                 /* Add computer to list */
                 IF TRANSLATE( macad, "0", " " ) = VALUE( stemval'.i.macaddr' ) THEN LEAVE i
              END
              IF VALUE( stemval'.0' ) < i THEN
              DO
                 IF isStem THEN
                    INTERPRET stemval'.i.name = STRIP( iface );'||stemval'.i.macaddr = TRANSLATE( macad, "0", " " );'||stemval'.i.ipaddr = STRIP( ipadd );'||stemval'.0 = i;retval = i'
                 ELSE
                    retval = retval||STRIP( iface )||' '||TRANSLATE( macad, "0", " " )||' '||ipadd||D2C(13)||D2C(10)
              END
           END
        END
    END
RETURN retval

13
Programming / List path to ObjectID's in plain rexx
« on: September 11, 2019, 10:50:05 pm »
This script take the object ID that point to a program object such as '<WP_CLIPV>' or a folder such as '<MMPM2_FOLDER>' and return path information.
  • It can list the file path to the object, path to the application (for WPProgram) and the path to the object with names as seen visually on the desktop.
  • The code use rexx and rexxutils without the need for wptools.
  • Haven't tried, but it's possible to add information about startup folder and parameters for WPProgram objects.
  • The script cache information during the first call so that consecutive calls return faster.
  • Use fastini to shorten the initial startup delay more.

You may want to optimize/shorten the script  ;)

Code: [Select]
/*
 * Filename: WPSObj.cmd
 *   Author: JanErik
 *  Created: Sat Aug  3 2019
 *  Purpose: Script to list Paths and Object names of Object ID's with rexx
 *  Changes:
 */
CALL rxFuncAdd "SysIni", "REXXUTIL", "SysIni"

objids = 'WP_NOWHERE NOOBJECT WP_CHESS WP_GAMES WP_TOOLS WP_SEEK XWP_FONTFOLDER WP_3DCAD MAH_FOLDER MAH_EXE'
DO i = 1 TO WORDS( objids )
   hID = RxObjIDPath( '<'||SUBWORD( objids, i, 1 )||'>' )
   SAY hID '"'!_PWH_!.hID.appPath'" ->' !_PWH_!.hID.fPath '"'!_PWH_!.hID.fName'"' '<-'||!_PWH_!.hID.isDir||'->' !_PWH_!.hID.oPath '"'!_PWH_!.hID.oName'"'
END
RETURN 0

RxObjIDPath: PROCEDURE EXPOSE !_PWH_!.
   PARSE ARG objID, refresh
   IF \DATATYPE( !_PWH_!.0, 'W' ) | refresh = 1 THEN
   DO
      /* Determine the currently active handles */
      hApp = SysIni( 'SYSTEM', 'PM_Workplace:ActiveHandles', 'HandlesAppName' )
      IF hApp = 'ERROR:' THEN
         hApp = 'PM_Workplace:Handles0'
      block = ''
      CALL SysIni 'SYSTEM', hApp, 'All:', 'blocks.'
      DO i = 1 To blocks.0
         block = block||SysIni( 'SYSTEM', hApp, blocks.i )
      END
      DROP blocks.
      DROP hApp
      !_PWH_!. = ''
      !_count_! = 0
      PARSE VALUE block WITH 5 block
      DO WHILE 0 < LENGTH( block )
         PARSE VALUE block WITH !_name_! 5 block
         SELECT
            WHEN !_name_! = 'DRIV' THEN
               PARSE VALUE block WITH 20 block
            WHEN !_name_! = 'NODE' THEN
            DO
               PARSE VALUE block WITH 3 !_oID_! 5 !_pID_! 7 25 !_isDir_! 27 !_fnSize_! 29 block
               !_oID_! = C2RX( !_oID_! )
               !_PWH_!.!_oID_!.isDir = C2X2D( !_isDir_! )
               !_PWH_!.!_oID_!.fID = C2RX( !_pID_! )
               !_PWH_!.!_oID_!.fPath = ''
               !_fnSize_! = C2X2D( !_fnSize_! )
               !_PWH_!.!_oID_!.fName = LEFT( block, !_fnSize_! )
               !_count_! = !_count_! + 1
               !_PWH_!.0 = !_count_!
               block = SUBSTR( block, !_fnSize_! + 2 )
            END
            OTHERWISE NOP
         END
      END
      IF SysIni( 'USER', 'PM_Abstract:FldrContent', 'All:', 'blocks.' ) <> 'ERROR:' THEN
      DO i = 1 TO blocks.0
         !_children_! = SysIni( 'USER', 'PM_Abstract:FldrContent', blocks.i )
         block = blocks.i
         IF !_PWH_!.block.isDir <> 1 THEN
            !_PWH_!.block.isDir = 1
         DO WHILE 0 < LENGTH( !_children_! )
            PARSE VALUE !_children_! WITH !_child_! 3 5 !_children_!
            !_child_! = C2RX( !_child_! )
            IF !_PWH_!.!_child_!.fID = '' THEN
               !_PWH_!.!_child_!.fID = block
         END
      END
      DROP blocks.
      DROP block
      DROP !_child_!
      DROP !_children_!
   END
   IF 0 < LENGTH( STRIP( objID ) ) THEN
   DO
      !_findID_! = C2RX( LEFT( SysIni( 'USER', 'PM_Workplace:Location', objID ), 2 ) )
      !_PWH_!.!_findID_!.oPath = RxObjPath( !_findID_! )
      RETURN !_findID_!
   END
RETURN 0
   
RxObjPath: PROCEDURE EXPOSE !_PWH_!.
   PARSE ARG findID
   !_path_! = ''
   !_PWH_!.findID.appPath = ''
   PARSE VALUE SysIni( 'USER', 'PM_Abstract:Objects', STRIP( findID, 'L', '0' ) ) WITH . 'WPProgramRef' +19 !_findID_! +2 'WPAbstract' +15 !_objSize_! +2 !_objName_! 'WPObject'
   IF !_findID_! <> '' THEN
   DO
      !_findID_! = C2RX( !_findID_! )
      IF 0 < LENGTH( !_objSize_! ) THEN
         !_PWH_!.findID.oName = LEFT( !_objName_!, C2X2D( !_objSize_! ) - 1 )
      IF !_PWH_!.!_findID_!.isDir <> 1 THEN
      DO
         !_PWH_!.findID.fName = !_PWH_!.findID.oName
         DO WHILE 0 < !_PWH_!.!_findID_!.fID
            !_path_! = '\'||!_PWH_!.!_findID_!.fName||!_path_!
            !_findID_! = !_PWH_!.!_findID_!.fID
         END
         !_path_! = !_PWH_!.!_findID_!.fName||!_path_!
         !_PWH_!.findID.appPath = !_path_!
      END
      !_findID_! = !_PWH_!.findID.fID
   END
   ELSE IF !_PWH_!.!_findID_!.isDir <> 1 THEN
      !_findID_! = !_PWH_!.findID.fID
   ELSE
      !_findID_! = findID
   !_path_! = ''
   DO WHILE 0 < !_PWH_!.!_findID_!.fID
      !_path_! = '\'||!_PWH_!.!_findID_!.fName||!_path_!
      !_findID_! = !_PWH_!.!_findID_!.fID
   END
   !_path_! = !_PWH_!.!_findID_!.fName||!_path_!
   !_PWH_!.findID.fPath = !_path_!
   !_path_! = !_path_!||'\'||!_PWH_!.findID.fName
   !_findID_! = findID
   DO WHILE 0 < !_PWH_!.!_findID_!.fID
      PARSE VALUE REVERSE( !_path_! ) WITH !_name_!'\'!_path_!
      !_name_! = REVERSE( !_name_! )
      !_path_! = REVERSE( !_path_! )
      IF SysGetEA( !_path_!||'\'||!_name_!, '.LONGNAME', 'EAValue' ) = 0 & EAValue <> '' THEN
      DO
         PARSE VAR EAValue EAType +2 EALength +2 EAValue
         IF EAType = 'FDFF'x THEN
            !_PWH_!.!_findID_!.oName = STRIP( EAValue, 'T', '00'x )
      END
      ELSE
         !_PWH_!.!_findID_!.oName = !_name_!
      !_findID_! = !_PWH_!.!_findID_!.fID
   END
   !_path_! = ''
   !_findID_! = !_PWH_!.findID.fID
   DO WHILE 0 < !_PWH_!.!_findID_!.fID
      !_path_! = '\'||!_PWH_!.!_findID_!.oName||!_path_!
      !_findID_! = !_PWH_!.!_findID_!.fID
   END
   !_path_! = !_PWH_!.!_findID_!.fName||!_path_!
RETURN !_path_!

XREV: PROCEDURE
   !_hex_! = STRIP( ARG( 1 ) )
   !_exp_! = ''
   IF \DATATYPE( !_hex_!, 'X' ) THEN RETURN !_exp_!
   DO i = 1 TO LENGTH( !_hex_! ) BY 4
      !_exp_! = STRIP( TRANSLATE( '1234', RIGHT( '0000'||STRIP( SUBSTR( !_hex_!, i, 4 ) ), 4 ), '3412' ) )||!_exp_!
   END
RETURN !_exp_!

C2RX: PROCEDURE
RETURN XREV( C2X( ARG(1) ) )

C2X2D: PROCEDURE
   chrs = ARG(1)
   retval = ''
   DO i = 1 TO LENGTH( chrs ) BY 2
      retval = retval||X2D( C2RX( SUBSTR( chrs, i, 2 ) ) )
   END
RETURN retval

//Jan-Erik

14
Programming / GetLANIPs in Rexx
« on: August 19, 2019, 07:10:45 pm »
This code detect available IP-numbers in the LAN...
Code: [Select]
...
   !_host_!.0 = 0
   CALL RxGetLANIP
   DO !_i_! = 1 TO !_host_!.0
      !_host_!.!_addr = !_host_!.!_i_!.!_addr
      CALL SockGetHostByAddr !_host_!.!_addr, '!_host_!.!_'
      PARSE VALUE RxClamDScan( 'zVERSION' ) WITH ...
... and yes, it's possible to use a rexx only procedure to scan files with a clam server using the newer calling method starting with the letter z.
Code: [Select]
RxGetLANIP: PROCEDURE EXPOSE !_host_!.
   !_lan_! = RXQUEUE( 'Create', 'GETLANIP' )
   CALL RXQUEUE 'Set', !_lan_!
   DO WHILE QUEUED() > 0; PARSE PULL; END;
   '@ping 255.255.255.255 56 1 2>>&1|RXQUEUE '!_lan_!
   !_i_! = 1
   DO WHILE QUEUED() > 0
      PARSE VALUE LINEIN( 'QUEUE:' ) WITH '64' . . !_host_!.!_i_!.!_addr':'.
      !_dot_! = POS( '.', !_host_!.!_i_!.!_addr )
      IF 0 < !_i_! THEN
      DO !_j_! = 2 TO 3
         !_dot_! = POS( '.', !_host_!.!_i_!.!_addr, !_dot_! + 1 )
         IF 0 = !_dot_! THEN !_j_! = 4
      END
      IF 0 < !_dot_! THEN !_i_! = !_i_! + 1
   END
   !_host_!.0 = !_i_! - 1
RETURN

Regards,
//Jan-Erik

15
Programming / OW, JNI (GCC built java 1.6) and parameters
« on: March 28, 2019, 06:20:23 am »
Hello,
I've now looked into how to use java 1.6 and with the help of the answer to the issue I posted quite some time ago, now managed to turn off floating point instructions.
Would appreciate if you can tell me how to also overcome the problem to feed the java code with one or more parameter(s).

LoadLib has been tested to dynamically load and use the dll for SQLite3 and Cairo, both the OW and GCC builds (the gcc builds installed with current ANPM) without recompile in between. The example code I used with SQLite3 and Cairo loaded with parameter "false" as they don't need the floating point fix. :-)
Try with OW as you like, but don't blame me if you run into problems.


Ohh, anyone that would like to help me to write code in vxrexx for this?
A gui to use java in the background etc.

Code: [Select]
#define INCL_DOS
#define INCL_DOSMODULEMGR
#define INCL_DOSMISC
#define INCL_DOSERRORS
#include <os2.h>
#include <stdio.h>
#include <ctype.h>
#include <jni.h>
#include <stdlib.h>
#include <iostream>
#include "LoadLib.hpp"

LoadLib *javm;
ULONG rc;

JNIEnv* create_vm() {
    javm = new LoadLib( "client\\jvm" );//, ".", false ); //when used with sqlite3 and cairo
    if( javm->rc == NO_ERROR ) {
        JavaVM* jvm;
        JNIEnv* env;

        JavaVMOption options[] = {
            { "-Xmx512m", NULL },
            { "-XX:+TraceClassLoading", NULL },//To see the origin of the problem class
            { "-Djava.class.path=.", NULL },  //D:\\Programs\\vxrexx\\projects\\ODBCADMN\\j4o";
            { "-Djava.library.path=.", NULL },// set native library path
            { "-Djava.compiler=NONE", NULL }, // disable JIT
            { "-verbose:gc", NULL },          // print gc messages
            { "-verbose:jni", NULL },         // print JNI-related messages
            { "-verbose:class", NULL }        // print class loading messages
        };

        JavaVMInitArgs args;
        args.version = JNI_VERSION_1_6;
        args.nOptions = sizeof( options ) / sizeof( JavaVMOption );
        args.options = options;
        args.ignoreUnrecognized = JNI_FALSE;

        InitFunc( javm->hmod, jint, JNI_CreateJavaVM, ( JavaVM **p_vm, void **p_env, void *vm_args ) );
        jint jrc = JNI_CreateJavaVM( &jvm, (void**)&env, &args );
//#ifdef __WATCOMC__
        if( jrc != JNI_OK )
            cerr << "Problems loading JVM" << endl;
        else
            cout << "JVM has been loaded sucessfully" << endl;
//#endif
        delete options;
        return env;
    }
    return NULL;
}

void invoke_class( JNIEnv* env ) {
  cout << "invoke class" << endl;

  jclass helloWorldClass;
  jmethodID mainMethod;
  jobjectArray applicationArgs;
  jstring applicationArg0;

  cout << "FindClass HelloWorld" << endl;
  helloWorldClass = env->FindClass( "HelloWorld" );

  cout << "main helloWorld" << endl;
  mainMethod = env->GetStaticMethodID( helloWorldClass, "main", "([Ljava/lang/String;)V" );

  cout << "New Args" << endl;
  applicationArgs = env->NewObjectArray( 1, env->FindClass( "java/lang/String" ), NULL );
  cout << "New UTF String to test parameters" << endl;
  applicationArg0 = env->NewStringUTF( "testparam" );
  cout << "Args" << endl;
  env->SetObjectArrayElement( applicationArgs, 0, applicationArg0 ); //KABOOM! Unless commented out. :-(

  cout << "void main" << endl;
  env->CallStaticVoidMethod( helloWorldClass, mainMethod, applicationArgs);
}

int main( int argc, char **argv ) {
    JNIEnv* env = create_vm();
    if( env )
        invoke_class( env );
    else
        return 1;
  return 0;
}

Pages: [1] 2 3