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.


Messages - Jan-Erik Lärka

Pages: 1 [2] 3 4 ... 13
16
Programming / Re: NetRexx on OS/2
« on: September 15, 2019, 07:59:39 am »
Here's a version of NetRexxC.cmd that is somewhat more sofisticated as it's based on my javarun code that tries to find and use the available java engine on the machine.

//Jan-Erik

Code: [Select]
/* Translate and compile a NetRexx program             */
/*                                                     */
/* use as:  NetRexxC hello [file2]...                  */
/*                                                     */
/*   which will use the NetRexx translator to          */
/*   translate hello.nrx to hello.java                 */
/*   then will use javac to compile hello.java         */
/*                                                     */
/* OPTIONS keywords may be added (with a -) before or  */
/* after the file specification, along with the extra  */
/* flags known to NetRexxC (such as -keep).   For      */
/* example:                                            */
/*                                                     */
/*    NetRexxC -keep -format -comments hello           */
/*                                                     */
/* Invoke with no parameters for a full list of flags. */
/*                                                     */
/* To run the class after compilation, specify -run as */
/* an option word.  Each file will be run in turn.     */
/*                                                     */
/*    NetRexxC -run hello                              */
/*                                                     */
/* Multiple programs may be specified; in this case    */
/* they are all run (if requested) after all compiles. */
/*                                                     */
/* ----------                                          */
/* 1996.09.02 -- handle Warnings from NetRexxC (rc=1)  */
/* 1996.12.14 -- use COM.ibm.netrexx.process           */
/* 1998.05.25 -- pass NETREXX_JAVA setting to java.exe */
/* 2011.09.01 -- use org.netrexx.process               */
/* 2011.09.01 -- remove -xms4M                         */

parse arg args
w=wordpos('-run', args)
if w>0 then do; run=1;   args=delword(args,w,1); end; else run=0
w=wordpos('-nocompile', args)
if w>0 then do; noc=1; end; else noc=0

/* ----- Translate & Compile ----- */
parse source system .
select                             /* system-specific options */
   when system='OS/2' then do
    '@echo off'
    PARSE SOURCE . . this
    CALL SysGetEA this, 'J_PATH', 'j_path'
    if LENGTH( j_path ) < 2 THEN DO
       SAY 'Searching for installed version of JAVA'
       PARSE UPPER VALUE rxFind( 'JAVA.EXE', ' -version', 'OPENJDK VERSION "1.' ) WITH j_path'\BIN'.
       IF LENGTH( j_path ) > 0 THEN
          CALL SysPutEA this, 'J_PATH', j_path
    end
    IF TRANSLATE( RIGHT( j_path, 4 ) ) = '\BIN' THEN
       j_path = LEFT( j_path, LENGTH( j_path ) - 4 )
    CALL SysGetEA this, 'NETRX_PATH', 'netrx_path'
    if LENGTH( netrx_path ) < 2 THEN DO
        SAY 'Searching for installed version of NetRexx'
        PARSE UPPER VALUE rxFind( 'NetRexxC.jar' ) WITH netrx_path'\LIB'.
        IF LENGTH( netrx_path ) > 0 THEN
          CALL SysPutEA this, 'NETRX_PATH', netrx_path
    end
    objID = 'NRXC'
    netrx_name = 'NetRexxKing'
    IF wpsObjectExist( '<WP_'objID'>' ) = 0 THEN
    DO
       setupstring = 'OBJECTID=<WP_'objID'>;EXENAME='this';PARAMETERS=[Type "-run" (without quotes) to run compiled script] %**P\%**F;ASSOCFILTER=*.nrx;ICONFILE='netrx_path'\'netrx_name'.ico;'
       IF SysCreateObject( 'WPProgram', 'NetRexx Compiler / Run', '<WP_DEVFLDR>', setupstring, 'U' ) <> 1 THEN
          CALL SysCreateObject 'WPProgram', 'NetRexx Compiler / Run', '<WP_DESKTOP>', setupstring, 'U'
       CALL rxAddBigIcon netrx_path'\'netrx_name'.png', '<WP_'objID'>'
    END
    PARSE UPPER VALUE this WITH this'\BIN'.
    IF 0 = POS( this'\LIB', TRANSLATE( VALUE( 'PATH',, 'OS2ENVIRONMENT' ) ) ) THEN
       CALL VALUE 'PATH', this'\lib;'VALUE( 'PATH',, 'OS2ENVIRONMENT' ), 'OS2ENVIRONMENT'
    IF 0 = POS( TRANSLATE( j_path )'\BIN', TRANSLATE( VALUE( 'PATH',, 'OS2ENVIRONMENT' ) ) ) THEN
       CALL VALUE 'PATH', '.;'j_path'\bin;'j_path'\lib;'VALUE( 'PATH',, 'OS2ENVIRONMENT' ), 'OS2ENVIRONMENT'
    /* Add option -norestart for OS/2s 1.0.2+ java.exe, for better display */
    'java -version 2>&1|rxqueue'; parse pull . '1.' subv ' '
    PARSE VALUE subv WITH subv'_'.
    javaopts = ''
     
    if subv>=6.0 then CALL VALUE 'CLASSPATH', '.;'this'\lib\NetRexxC.jar;'j_path'\lib\tools.jar', 'ENVIRONMENT'
    else if subv>=4.1 then NOP
    else if subv>=0.2 then javaopts='-norestart'; else if subv <> '' then do; say subv; javaopts='-noasyncgc'; end

      /* Add any options from NETREXX_JAVA environment variable */
    if subv < 4.2 then
    do
        nrjava=value('NETREXX_JAVA',,'ENVIRONMENT')
        if nrjava\='' then javaopts=javaopts nrjava
    end
    else
        javaopts=value('NETREXX_JAVA',,'ENVIRONMENT')
  end
  otherwise
    /* Add any options from NETREXX_JAVA environment variable */
    javaopts=value('NETREXX_JAVA',,'ENVIRONMENT')
  end

do queued(); parse pull .; end
old_trace = TRACE( 'O' )z
'java -version'
'java ' javaopts 'org.netrexx.process.NetRexxC' args
CALL TRACE old_trace

/* ----- Run ----- */
if rc<=1 & run then do
  if noc then say 'Run option ignored as -nocompile specified'
  else do
    /* This section of code is still OS/2-specific */
    do forever /* find the file parameters */
      parse var args file args
      if file='' then leave
      if left(file,1)='-' then iterate
      filename=filespec('n', file); parse var filename fn '.' fe
      /* Now determine the exact case of the class, for java commands */
      file=fn'.class'
      call SysFileTree file, 'foo.', 'FO'
      if foo.0<>1 then do
        if foo.0=0 then say 'Cannot find file:' file
        if foo.0>1 then
          say 'File "'file'" is not a unique specification'
        exit 1;
      end
      file = filespec( 'Name', foo.1 ) /* is now correct case */
      parse var file fn '.' fe
      say 'Running' fn '...'
      'java' fn
    end
  end
end
ELSE
  PARSE PULL
exit rc

rxChk: PROCEDURE
 DO WHILE QUEUED() > 0; PARSE PULL; END;
 org_trace = TRACE( 'O' )
 '@'||ARG(1)||ARG(2)||' 2>>&1 | RXQUEUE'
 CALL TRACE org_trace
 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_!.
   PARSE VALUE REVERSE( SysSearchPath( 'PATH', ARG(1) ) ) WITH .'\'fpath
   fpath = REVERSE( fpath )
   IF ARG() > 1 & LENGTH( fpath ) > 0 THEN
      fspec = rxChk( fpath'\'ARG(1), ARG(2), ARG(3), fpath )
   ELSE IF STREAM( fpath'\'ARG(1), 'C', 'QUERY EXISTS' ) <> '' THEN
      fspec = fpath
   ELSE fspec = ''
   IF LENGTH( fspec ) > 0 THEN RETURN fspec
   CALL LINEOUT 'STDERR', VALUE( 'PROGRAMS',,'ENVIRONMENT' )
   CALL SysFileTree VALUE( 'PROGRAMS',,'ENVIRONMENT' )||'\*'||ARG(1), '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 )||'\*'||ARG(1), '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 ''   
   
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

Script has now been modified to support 4OS2 as well.
Sept 18, 2019

17
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

18
Programming / Re: List path to ObjectID's in plain rexx
« on: September 12, 2019, 05:39:22 pm »
Very good  :)

One can modify the first part to measure the time.
Once cached (as seen on the first line), each call to retrieve objects doesn't take long.
Code: [Select]
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 )
   CALL TIME 'R'
   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'" (' TIME( 'E' ) ')'
END
RETURN 0

output:
Code: [Select]
E0E8 "" -> C: "NOWHERE" <-1-> C: "Nowhere" ( 2.130000 )
5245 "" ->  "" <-->  "" ( 0 )
DC91 "C:\OS2\APPS\OS2CHESS.EXE" -> C:\DESKTOP\PROGRAMS\GAMES "Chess" <--> C:\Desktop\Programs\Games "Chess" ( 0.040000 )
84AE "" -> C:\DESKTOP\PROGRAMS "GAMES" <-1-> C:\Desktop\Programs "Games" ( 0 )
6D42 "" -> C:\DESKTOP\PROGRAMS "UTILITIES" <-1-> C:\Desktop\Programs "Utilities" ( 0.010000 )
9DE6 "C:\OS2\APPS\PMSEEK.EXE" -> C:\DESKTOP\PROGRAMS\UTILITIES "Seek and Scan Files" <--> C:\Desktop\Programs\Utilities "Seek and Scan Files" ( 0 )
68A2 "" -> C:\DESKTOP\COMPUTER\SYSTEM SETUP "FONTS" <-1-> C:\Desktop\Computer\System Setup "Fonts" ( 0.030000 )
097C "D:\PROGRAMS\VIRTUALBOX\BIN\3DCAD.CMD" -> C:\DESKTOP\COMPUTER\COMMAND PROMPTS "3D CAD" <--> C:\Desktop\Computer\Command Prompts "3D CAD" ( 0.010000 )
C150 "" -> C:\DESKTOP\PROGRAMS\GAMES "MAHJONGG SOLITAIRE" <-1-> C:\Desktop\Programs\Games "Mahjongg Solitaire" ( 0.010000 )
2D7C "C:\OS2\APPS\MAHJONGG.EXE" -> C:\DESKTOP\PROGRAMS\GAMES\MAHJONGG SOLITAIRE "Mahjongg" <--> C:\Desktop\Programs\Games\Mahjongg Solitaire "Mahjongg" ( 0 )

19
Programming / Re: List path to ObjectID's in plain rexx
« on: September 12, 2019, 12:40:03 pm »
Retrieval of the values for object id's in the users ini-file require < and >
Measure the time to retrieve the first object compared to the second, third etc. not the script itself.
It has to load and build entries from the ini-files the first time.
Object Rexx use built in functionality, so this is intended for Classic Rexx.
External libraries are seldom a part of the base OS and call for something as this.

Code: [Select]
IF \DATATYPE( !_PWH_!.0, 'W' ) | refresh = 1 THEN restrict the number of times the script has to fill the stem to only the first time while it retrieve the entry once for each <objectid> with
Code: [Select]
PARSE VALUE SysIni( 'USER', 'PM_Abstract:Objects', STRIP( findID, 'L', '0' ) ) WITH . 'WPProgramRef' +19 !_findID_! +2 'WPAbstract' +15 !_objSize_! +2 !_objName_! 'WPObject'

20
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

21
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

22
Applications / Re: PostgreSQL database initialization
« on: May 30, 2019, 03:33:19 pm »
Hello,

I've seen similar issues with it as well as with earlier builds.
The PostgreSQL team doesn't want to add IBM850 as a codepage. I also have issues with Swedish (sv_SE) on top of that, to support national characters such as åäö and ÅÄÖ.

See further down for a cmd-script by Paul that should work with German (de_DE).
Does it work better for you?

==pg.cmd, adjust paths to current version==
@ECHO OFF
SET PGINST_HOME=C:\OS2TOOLS\PG843
SET PGDB_HOME=D:/db/pg840data

SET OLDPATH=%PATH%
SET PATH=%PGINST_HOME%\bin;%PATH%

SET OLDBEGINLIBPATH=%BEGINLIBPATH%
SET BEGINLIBPATH=%PGINST_HOME%\bin;%PGINST_HOME%\lib;%BEGINLIBPATH%

SET OLDLANG=%LANG%
SET LANG=de_DE

call MODE 102,80

IF "%1"=="init" GOTO INITDB
IF "%1"=="start" GOTO STARTDB
IF "%1"=="stop" GOTO STOPDB
GOTO ERRORMSG


:INITDB
CMD /C  "initdb.exe -D %PGDB_HOME% --encoding=UTF8 --no-locale"
REM CMD /C  "initdb.exe -D %PGDB_HOME% --encoding=ISO8859-1 --locale=de_DE"
GOTO CLEANUP


:STARTDB
CMD /C "pg_ctl.exe -D %PGDB_HOME% -l "%PGINST_HOME%\postgres.log" start"
GOTO CLEANUP


:STOPDB
CMD /C "pg_ctl.exe -D %PGDB_HOME% stop"
GOTO CLEANUP


:ERRORMSG
ECHO.
ECHO ERROR:
ECHO ======
ECHO Only the parameters 'init', 'start' and 'stop' are supported!
ECHO.
GOTO CLEANUP

:CLEANUP
SET PATH=%OLDPATH%
SET BEGINLIBPATH=%OLDBEGINLIBPATH%
SET LANG=%OLDLANG%

23
Programming / Re: OW, JNI (GCC built java 1.6) and parameters
« on: April 07, 2019, 08:20:31 pm »
This is what I tried:

Ripped some of the code out and created reusable #define that I call with
AddFPEHandler();
...
main(...) {
    InitNoFPE( javm );
    NoFPE( javm, client\\jvm, . );
...
The problem I face now is that the fpeHandler get called twice followed by a bunch of java class loading/debug lines before it stop (but doesn't end) and use up a cpu core.

How do I get passed that?

Code: [Select]
/* r = return type, f = funtion name, p = parameter(s) */
#define InitFunc( h, r, f, p )                     \
    r( __syscall *f)p;                             \
    rc = DosQueryProcAddr( h, NULL, "_"#f, (PFN *) &f ); /*GCC*/\
    if( rc != 0 )                                  \
        rc = DosQueryProcAddr( h, NULL, #f, (PFN *) &f );/*OW*/

/* v = variable name */
#define InitNoFPE( v )                             \
    EXCEPTIONREGISTRATIONRECORD ex = { 0, };       \
    LoadLib *v = new LoadLib();                    \
    _control87( 0, MCW_EM );                       \
    if( v ) {                                      \
        ex.ExceptionHandler = ( ERR )fpeHandler;   \
        DosSetExceptionHandler( &ex );             \
    }

/* v = variable name, n = name of dll, p = path to dll */
#define NoFPE( v, n, p )                           \
    v->LoadLibrary( #n, #p );                      \
    if( v->rc == NO_ERROR ) {                      \
        _control87( 0, MCW_EM );                   \
        DosSetExceptionHandler( &ex );             \
    }

// this handler was excerpted from Mozilla repository
#define AddFPEHandler()                            \
static ULONG fpeHandler( PEXCEPTIONREPORTRECORD p1,\
                   PEXCEPTIONREGISTRATIONRECORD p2,\
                   PCONTEXTRECORD p3,              \
                   PVOID p4 )                      \
{                                                  \
    switch( p1->ExceptionNum )                     \
    {                                              \
        case XCPT_FLOAT_DENORMAL_OPERAND:          \
        case XCPT_FLOAT_DIVIDE_BY_ZERO:            \
        case XCPT_FLOAT_INEXACT_RESULT:            \
        case XCPT_FLOAT_INVALID_OPERATION:         \
        case XCPT_FLOAT_OVERFLOW:                  \
        case XCPT_FLOAT_STACK_CHECK:               \
        case XCPT_FLOAT_UNDERFLOW:                 \
        {                                          \
            unsigned cw = p3->ctx_env[0];          \
            if( ( cw & MCW_EM ) != MCW_EM ) {      \
            /* Mask out all floating point exceptions */\
                p3->ctx_env[0] |= MCW_EM;          \
            /* Following two lines set precision to 53 bit mantissa. See jsnum.c */\
                p3->ctx_env[0] &= ~MCW_PC;         \
                p3->ctx_env[0] |= PC_53;           \
                printf("----- XCPT_CONTINUE_EXECUTION\n");\
                return XCPT_CONTINUE_EXECUTION;    \
            }                                      \
            break;                                 \
        }                                          \
    }                                              \
    return XCPT_CONTINUE_SEARCH;                   \
}

24
Programming / Re: Templates
« on: April 03, 2019, 06:56:59 pm »
Since I have a text file with all the details, including icon name would it be possible to use something like a rexx script to do everything in one run and if so does anyone have such a script?
I do have that script...

Run the script once and it will create a program object in the folder for command prompts ;)
It then also associate itself with .jar-files
Double click on a .jar-file and it will ask you if it should create a program object for you.
The program object contain parameters that you can adjust and/or remove/add.
It use any existing .ico file with the same name as the .jar file as it create the program object.
It work out of the box with both GenealogyJ, JDownloader2.

You can translate the message files to your own language if you like.

25
Programming / Re: OW, JNI (GCC built java 1.6) and parameters
« on: April 02, 2019, 10:47:48 pm »
This originate from http://trac.netlabs.org/java/ticket/245 and the reply to http://lvzuufx.blogspot.com/2014/09/os2-codes-prevent-sigfpe.html
I like the idea to write once and use everywhere, so the file was my interpretation of the blog post, how to to solve the problem .

OW GUI resemble Borland C++ that was taught out at school where one add the files to compile and it ... figure out how to create the exe.
The #define INITPROC(...) is what I came up with to address the limitation to call gcc built dlls from code compiled with OW.

Lars is quite right, but I can't quite grasp how/where to change the code to get it right. I also downloaded and looked at the code for XWPDeamon, but can't quite see/figure it out from there either.
I would appreciate a direct rewrite of the code to help me out.

Regards,
//Jan-Erik

26
Programming / Re: OW, JNI (GCC built java 1.6) and parameters
« on: March 28, 2019, 10:13:57 pm »
Interesting...

as I received "divide by zero" messages without it, the initial problem went away and was replaced by "inexact result" as I added the case for divide by zero, but all float-related went away as I added the other XCPT_FLOAT_... cases.

Would appreciate if you could give me a brief example how it should be resolved.

Regards,
//Jan-Erik

27
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;
}

28
It was Arca Noae that started the development of Arca Noae Package Manager (ANPM) and they offer it free of charge. It's a product that we may take for granted or wish has more features built in, but it provides you and me as end users (and devlopers) with a point and click application to install and update software components and libraries. Some of you have started to explore how to create packages for it,something that is great, wow. OS2World or Voice shuld host a repository of those packages to select from.

Lewis himself is involved in the community and work as treasurer of the Warpstock board:
http://www.warpstock.org/staticpages/index.php?page=directors
sometimes just passive reader while at other times take part in discussions.

We've always had to choose the hardware with care and Audio and WiFi is no different. This cheap laptop I write this on, came with an Atheros WiFi chip that I wish there where a driver for.
Arca Noae am aware of my need for a driver for this specific chip, just as with each of you and at the same time look at the bigger picture to see that they need to continue to resolve more things, but in another order that I can see or would choose from my perspective. The development resources are limited but they have a plan that they re(de)fine as time progress.

Am quite fund of the idea to develop new unified (qt-)libraries and routines to port drivers and software as it should allow us to get modern, stable and tested drivers and software that we otherwise never can expect. It may take some more time to get there, but we've seen many useful solutions that share common parts on OS/2.

More details:

The Linux way to develop, alter a lot of the core with each update, instead of keeping a stable mature core/interface. It affect projects like UniAud and Multimac etc.

* It seem as if they've modified so much in the kernel sources now that it's no longer possible to recompile the Linux ALSA code on OS/2. They have therefore started to work on a new Audio driver.
( Listen to the video URL below )

* WiFi has been delayed as the Linux kernel sources, that is the base for the Multimac library, change so much with each update.
( Listen to the video URL below )

Information has been obtained from this video url below and other Warpstock presentations made by David Azarewicz:
https://youtu.be/yr0dKX3YMdU?list=PL4pjffCdj7wQ1sMlO0j-gbGSUEnibfxwc
From about 30:00 you will hear David say it himself: He has spent time fixing boot issues on new hardware and resources are limited.

While I want WiFi and Audio drivers as well I think it's a bit to far to say that Arca Noae has the community set to the lowest priority.
It's just that they are very busy and working very hard. One adjustment to the video driver Panorama improved the performance for most systems but caused some (like mine) to not boot to desktop. Arca Noae resolved that issue very professionally and Panorama now handle many more (some even obscure) systems after that.

Regards,
//Jan-Erik

29
Programming / Re: Capture window that extend beyond the active desktop
« on: August 21, 2018, 06:24:48 pm »
The attached MovieContactSheet101.zip (2 posts ago) contain the application you can see in the images.
It is so close to be complete!

30
Programming / Re: Capture window that extend beyond the active desktop
« on: August 20, 2018, 10:42:41 pm »
What did you suggest?
Enlarge your Firefox/Seamonkey window over 2 or more XPager pages, the more the better.
Enable screen capture of program window in PMView and activate it.
Here it flip around and trigger all pages in sequence that the window span over.

I'd be quite surprised if PMView is responsible for moving the Firefox main window as well hide/show all other open windows to achieve it! Calling/Triggering XPager is therefore more likely.

Or are you trying to say that you can capture all desktops, but that cropping and merging is the problem?

Yes, merging multiple captured images is the current problem now as I've adjusted the code to move the viewport around on the active desktop until it has captured all required parts. It doesn't handle other application windows that is in the way.
It use the full size needed for the desired window and move it around. The result is that each image will contain black area(s) and one part that was visible for that specific move. If one combine the non black parts, exclude the black area(s) that is, of the images, one get the complete one.

I don't know what you mean by "exclude black areas"? Surely you don't want me to write yours (no GCC DLLs, 1.5 supported different bitmap file formats, exactly 1 desktop size-related API in use), and I'd consider using NCONVERT or tools like that. If you cannot calculate which part of each bitmaps you need, then features like its crop or autocrop (cropping) and watermark (merging) may be helpful somehow. And I was just saying that ePager isn't involved, a.o. based on the desktops' background.

My Rexx image support dll "rxImgSze" rely on gbm and handle enough file formats. Just need to add C/C++ code to it to either grab what I want somehow or stitch parts (see attached example images) together.
It would be a lot better if one could get the full image as I have the window handle and not just the visible portion.
How can one print or use windows that extend beyond the desktop to retrieve their bitmap representation?

Pages: 1 [2] 3 4 ... 13