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 ... 10
1
Programming / Re: JSon to Rexx (stem)
« on: February 10, 2018, 10:43:07 pm »
New and improved :)
Tested on json from https://glosbe.com/ as well as openweather.

Code: [Select]
/*
 * Filename: fromJSon.cmd
 *   Author: JANERIK
 *  Created: Sat Feb  3 2018
 *  Purpose:
 *  Changes:
 */

IF ARG() > 0 THEN
    IF STREAM( ARG(1), 'C', 'QUERY EXISTS' ) <> '' THEN
        f_name = ARG(1)
    ELSE
        f_name = 'london.json'
ELSE
    f_name = 'london.json'

IF STREAM( f_name, 'C', 'QUERY EXISTS' ) = '' THEN RETURN 1
f_size = STREAM( f_name, 'C', 'QUERY SIZE' )
f_input = CHARIN( f_name, 1, f_size )
CALL STREAM f_name, 'C', 'CLOSE'
!_arrays_! = 'json.'
DO WHILE 0 < RxFromJSon( f_input )
    CALL CHAROUT 'STDERR', 'Parts of the file missing! Press Enter to read it again. '
    PARSE PULL
    f_size = STREAM( f_name, 'C', 'QUERY SIZE' )
    f_input = CHARIN( f_name, 1, f_size )
    CALL STREAM f_name, 'C', 'CLOSE'
END
SAY 'Press <Enter> to show JSON as flat Stem'
PARSE PULL
DO i = 1 TO json.!.0
   SAY json'.!.'i' -> 'json.!.i' => 'VALUE( json.!.i )
END
SAY 'Press <Enter> to show JSON Tree View Stem'
PARSE PULL
CALL RxRecursive 'json'
RETURN 0

RxRecursive: PROCEDURE EXPOSE (!_arrays_!) stem
   stm = ARG(1)
   DO i = 1 TO VALUE( stm'.0' )
      IF SYMBOL( VALUE( stm'.i' ) ) = 'VAR' THEN
         SAY stm'.'i' -> 'VALUE( stm'.i' )' => 'VALUE( VALUE( stm'.i' ) )
      IF DATATYPE( VALUE( stm'.i.0' ), 'W' ) THEN
         CALL RxRecursive stm'.'i
   END
RETURN 0

RxFromJSon: PROCEDURE EXPOSE (!_arrays_!) stem
   IF SYMBOL( 'stem' ) = 'LIT' THEN
      !_stem_! = 'json'
   ELSE
      !_stem_! = STRIP( stem, 'T', '.' )
   IF SYMBOL( '!_arrays_!' ) = 'LIT' THEN
      !_arrays_! = !_stem_!'.'
   !_json_! = !_stem_!
   !_tree_! = !_stem_!
   !_str_! = STRIP( ARG(1) )
   !_delim_! = ',:'
   !_quote_! = '""""'||"''''"
   !_group_! = '[]{}'
   !__tag__! = !_quote_!||!_group_!||!_delim_!
   !_counter_! = 0
   DO FOREVER
      old_trace = TRACE( 'O' )
      !_next_! = 1
      !_stop_! = LENGTH( !_str_! )
      DO !_i_! = 1 TO LENGTH( !__tag__! )
         !_char_! = SUBSTR( !__tag__!, !_i_!, 1 )
         !_pos_!.!_i_! = POS( !_char_!, !_str_! )
         IF 8 < !_i_! THEN
         DO
            DO !_j_! = 1 TO 7 BY 2
               !_k_! = !_j_! + 1
               IF RxIsBetween( !_pos_!.!_j_!, !_pos_!.!_i_!, !_pos_!.!_k_! ) THEN
                  !_pos_!.!_i_! = POS( !_char_!, !_str_!, !_pos_!.!_k_! + 1 )
            END
         END
         ELSE
            !_pos_!.!_i_! = POS( !_char_!, !_str_!, !_next_! )
         
         IF !_i_! < 9 & 0 < !_pos_!.!_i_! THEN
         DO
            IF !_i_! % 2 = 0 THEN
               !_stop_! = MIN( !_stop_!, !_pos_!.!_i_! + 1 )
            !_next_! = !_pos_!.!_i_! + 1
         END
            ELSE !_next_! = 1
         !_sorted_!.!_i_! = !_pos_!.!_i_! !_char_!
      END
      DO !_i_! = 1 TO LENGTH( !__tag__! )
         DO !_j_! = !_i_! + 1 TO LENGTH( !__tag__! )
            IF SUBWORD( !_sorted_!.!_j_!, 1, 1 ) < SUBWORD( !_sorted_!.!_i_!, 1, 1 ) & 0 < SUBWORD( !_sorted_!.!_j_!, 1, 1 ) | 0 = SUBWORD( !_sorted_!.!_i_!, 1, 1 ) THEN
            DO
               !_temp_! = !_sorted_!.!_i_!
               !_sorted_!.!_i_! = !_sorted_!.!_j_!
               !_sorted_!.!_j_! = !_temp_!
            END
         END
         !_ord_!.!_i_! = SUBWORD( !_sorted_!.!_i_!, 1, 1 )
         IF 0 < !_ord_!.!_i_! THEN
            !_chr_!.!_i_! = SUBWORD( !_sorted_!.!_i_!, 2, 1 )
         ELSE
            !_chr_!.!_i_! = ''
      END
      !_i_! = 2
      CALL TRACE old_trace
      IF 0 < POS( !_chr_!.1, ',}]' ) THEN
      DO
         !_lpos_! = LASTPOS( '.', !_json_! ) - 1
         IF 0 < !_lpos_! THEN
            !_json_! = LEFT( !_json_!, !_lpos_! )
         !_lpos_! = LASTPOS( '.', !_tree_! ) - 1
         IF 0 < !_lpos_! THEN
            !_tree_! = LEFT( !_tree_!, !_lpos_! )
      END
      ELSE IF !_chr_!.3 = ':' THEN
      DO
         DROP result
         !_key_! = SUBSTR( !_str_!, !_ord_!.1 + LENGTH( !_chr_!.1 ), !_ord_!.2 + LENGTH( !_chr_!.2 ) - !_ord_!.1 - LENGTH( !_chr_!.1 ) - 1 )
         !_num_! = 3 + ( 0 < POS( !_chr_!.4, !_quote_! ) | SUBSTR( !_group_!, POS( !_chr_!.4, !_group_! ) + 1, 1 ) = !_chr_!.5 )
         !_num_2_! = !_num_! + 1
         !_val_! = STRIP( SUBSTR( !_str_!, !_ord_!.!_num_! + LENGTH( !_chr_!.!_num_! ), !_ord_!.!_num_2_! + LENGTH( !_chr_!.!_num_2_! ) - !_ord_!.!_num_! - LENGTH( !_chr_!.!_num_! ) - 1 ) )
         !_json_! = !_json_!'.'!_key_!
         IF 0 < LENGTH( !_val_! ) | 0 < POS( !_chr_!.4, !_quote_! ) THEN
         DO
            INTERPRET !_json_!' = "'!_val_!'"'
            !_counter_! = !_counter_! + 1
            CALL VALUE !_stem_!'.!.'!_counter_!, !_json_!
            CALL VALUE !_stem_!'.!.0', !_counter_!
            !_val_! = VALUE( !_tree_!'.0' )
            IF \DATATYPE( !_val_!, 'W' ) THEN
               !_val_! = 0
            !_val_! = !_val_! + 1
            CALL VALUE !_tree_!'.0', !_val_!
            !_tree_! = !_tree_!'.'!_val_!
            CALL VALUE !_tree_!, !_json_!
         END
         !_i_! = !_num_! + 1 + ( 0 < POS( !_chr_!.4, !_quote_! ) | SUBSTR( !_group_!, POS( !_chr_!.4, !_group_! ) + 1, 1 ) = !_chr_!.5 )
      END
      ELSE IF 0 < POS( !_chr_!.1, '{[' ) THEN
      DO
         IF !_chr_!.1 = '[' THEN
            !_val_! = 0
         ELSE
            !_val_! = VALUE( !_json_!'.0' )
         IF DATATYPE( !_val_!, 'W' ) THEN
         DO
            !_val_! = !_val_! + 1
            CALL VALUE !_json_!'.0', !_val_!
            !_json_! = !_json_!'.'!_val_!
            CALL VALUE !_tree_!'.0', !_val_!
            !_tree_! = !_tree_!'.'!_val_!
            CALL VALUE !_tree_!, !_json_!
         END
      END
      IF 0 < !_ord_!.!_i_! THEN
         !_str_! = SUBSTR( !_str_!, !_ord_!.!_i_! )
      ELSE LEAVE
   END
RETURN 0 < POS( '.', !_tree_! )
   
RxIsBetween: PROCEDURE
RETURN ARG(1) < ARG(2) & ARG(2) < ARG(3)

2
Setup & Installation / Re: How to - Install Fonts on OS/2
« on: January 08, 2018, 12:25:13 pm »
Ehm... Think I found the code with a prevoid version of freetype/2 then

3
Setup & Installation / Re: How to - Install Fonts on OS/2
« on: January 07, 2018, 09:34:21 am »
That one will require a reboot to make the font available, though.

Maybe I should add a function to RXUTILEX.DLL for registering fonts without a reboot... well, something for the wish list, perhaps. :)
I wouldn't mind if RXUTILEX.DLL would contain a function to register one or more fonts.
By the way, the script is a variation to the one Alex Taylor provide on his site.

4
Setup & Installation / Re: How to - Install Fonts on OS/2
« on: January 07, 2018, 12:53:59 am »
You can also try a REXX script that can add .ttf-files
This script can extract and add them from .zip-files and WarpIn Packages as well

5
Applications / PM app ClamDScan
« on: January 05, 2018, 07:52:37 pm »
It is mulithreaded* and use clamdscan to scan for various threats.

Use clamd on another machine if set up in the clamd.conf file.

Add it to Folder actions (XWP) and you can right click on a folder and scan the whole folder structure.

It tell you what file it has processed (percent and first number) and how many more files this and previous thread that has finished contain* and the total number of files to process in this folder/drive.

ETA: 5h is the Estimated Time of Arrival calculated on the number of files processed and the number of files left to process, not their sizes.

​You can also notice the subtle shine that pass over the progress bar. Add a copy of the DLL in the libpath so it can load and use the progress bar images.

It create a folder on the desktop called "Alert" with the files it find that contain
Malware Trojan Worm Downloader etc.
It attach the Icons it find based on the type name of the threat so one can design ones own icons and place them in the folder next to the executable.

It also add a comment to the file of what type of threat it has detected and set the association type to the same, thus somewhat reduce the ease to double-click-open the file.

*It use multi threading to speed up processing.
It first list files in the current folder and add those so it can start to scan almost right away (if the current folder doesn't contain many files). Then it hand over to up to 5 additional threads (if there are 5 or more sub folders present) to list the files there. As each thread finish, the progress bar and title bar information adjust itself to the information while it scan queued files.

6
Applications / Re: Updated Postgresql/2 builds
« on: January 01, 2018, 07:27:32 pm »
initdb in the 9.4 and 9.6 build doesn't behave like they do in 9.3:

selecting dynamic shared memory implementation ... sysv
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... postgres: could not look up effecti
ve user ID 0: No such file or directory
child process exited with exit code 1
initdb: removing data directory "D:/NLSTeam"

7
Programming / Re: htonl in REXX
« on: December 26, 2017, 10:53:15 am »
It's not true reverse, it's more reverse in group of 2.
But that is if one start with a number and use Hex to do the swap.

What do you use as input?

8
Programming / htonl and ntohl in REXX
« on: December 20, 2017, 06:38:33 am »
Quote
Description
htonl(...) call convert an host-byte order integer to internet network-byte order.
htonl(...) call also convert an internet network-byte order integer to host-byte order.

Strange that it doesn't use ntohl(...) to convert back to little endian like most languages. Would seem clearer.
True, the gcc version wrap a function and try to overcome the problem with a check.

Description
htonl(...) call convert an host-byte order integer to internet network-byte order (long).
ntohl(...) call convert an internet network-byte order integer to host-byte order (long).

Code: [Select]
htonl: PROCEDURE
   swp = swap( ARG(1) )
   IF ARG(1) < swp THEN
      RETURN swp
RETURN ARG(1)

ntohl: PROCEDURE
   swp = swap( ARG(1) )
   IF swp < ARG(1) THEN
      RETURN swp
RETURN ARG(1)

swap: PROCEDURE
   hex = D2X( ARG( 1 ) )
   exp = ''
   DO i = 1 TO LENGTH( hex ) BY 8
      exp =  STRIP( TRANSLATE( '12345678', RIGHT( STRIP( SUBSTR( hex, i, 8 ) ), 8, '0' ), '78563412' ) )||exp
   END
RETURN X2D( exp )
gcc's htonl use __swab32 that does the same thing in the background in its own way and have the same "problem" as one then have to know if it has been converted.

9
Programming / htonl in REXX
« on: December 19, 2017, 07:19:59 pm »
The socket call translates a long integer from host-byte order to network-byte order.

Syntax
htonl( a )

Parameters
a
integer (whole) number to be converted to/from network-byte order (on little endian systems).

Description
htonl(...) call convert an host-byte order integer to internet network-byte order.
htonl(...) call also convert an internet network-byte order integer to host-byte order.

The internet network requires addresses and ports in network standard-byte order.
Use the htonl(...) call to convert the host integer representation of addresses and ports to internet network-byte order.

Returns
The translated integer

Example:
SAY htonl( 16384 )  //4194304
SAY htonl( 4194304 )  //16384

Code:
Code: [Select]
htonl: PROCEDURE
   hex = D2X( ARG( 1 ) )
   exp = ''
   DO i = 1 TO LENGTH( hex ) BY 8
      exp =  STRIP( TRANSLATE( '12345678', RIGHT( STRIP( SUBSTR( hex, i, 8 ) ), 8, '0' ), '78563412' ) )||exp
   END
RETURN X2D( exp )

ClamAV use it for zINSTREAM
Other applications that communicate over the network

Regards,
//Jan-Erik

10
Utilities / problems with sh.exe
« on: June 11, 2017, 10:13:43 pm »
I've successfully installed PostgreSQL in the past.
One has to use initdb.exe and the various executables to create databases, add tables, data and functions etc.
I decided to try once more, but now stumble on messages that sh.exe can't do this and that.
I've tried to rename ash, bash, dash to sh but the problem remain.
What has been changed and why? Fix?

Issue #164
initdb.exe from PostgreSQL apparently use sh.exe internally to initialize a new database structure.

Command line: initdb -E UTF8 -D D:/NLSTeam
Has worked in the past, but not now with installed libraries up to date according to ANPM.

Version: PostgreSQL 8.2.5 b2
Output:
sh.exe: 1: cannot create nul:: Directory nonexistent
fgets failure: No such file or directory
The program "postgres" is needed by initdb but was not found in the
same directory as "D:/Programs/postgres/bin/initdb".
Check your installation.
Couldn't initalize database

Version: PostgreSQL 9.1.7
Output:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale sv_SE.IBM-850.
could not determine encoding for locale "sv_SE.IBM-850": codeset is "IBM-850"
could not determine encoding for locale "sv_SE.IBM-850": codeset is "IBM-850"
The default text search configuration will be set to "swedish".

creating directory D:/NLSTeam ... ok
creating subdirectories ... ok
selecting default max_connections ... sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
10
selecting default shared_buffers ... sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
400kB
creating configuration files ... ok
creating template1 database in D:/NLSTeam/base/1 ... sh.exe: 1: D:Programspgsqlb
inpostgres.exe: not found
child process exited with exit code 127
initdb: removing data directory "D:/NLSTeam"
SYS1808:
The process has stopped. The software diagnostic
code (exception code) is 0005.
Couldn't initalize database

11
Applications / Re: Regina REXX vs. OS/2 REXX
« on: January 23, 2017, 12:14:57 pm »
You can download regina (3.9.2) from rexx.org and compile to whatever platform you like.
I use OpenWatcom btw but not in OS/2.
It's even possible to translate it to various languages.

We want IBM to release the OS/2 specific code (WPS/SOM support etc.) so we can compile it and Open Object REXX and get up to date.

//Jan-Erik

12
Programming / Re: REXX help - check to see if file is present.
« on: December 06, 2016, 03:30:31 pm »
Perhaps something like:
filedate = SPACE( TRANSLATE( STREAM( fileName, "C", "QUERY DATETIME" ),, SPACE( TRANSLATE( XRANGE(),, XRANGE( 0, 9 ) ), 0 ) ), 0 )

//Jan-Erik Lärka

13
Programming / Re: Poll: Your favorite text editor
« on: October 21, 2016, 12:24:27 pm »
The latest version of FTE2 fold DO ... END nicely.
Though inserting code from the menu (to include rexxutil) still indent the code as before.
"Alt + \" fix it though.

Embed FTE within other software?

//Jan-Erik

14
General Discussion / Re: Need some help with REXX
« on: September 06, 2016, 07:24:09 pm »
This script resemble the first one, especially the beginning.

The part that parse the input file should be easier to follow as it use just a few lines within a loop.

This script can even parse the info.txt-file correctly, and leave out the comments and the part with the correct result.

Code: [Select]
/*
 * Filename: raiko62.cmd
 *   Author: Jan-Erik
 *  Created: Tue Sep  6 2016
 *  Purpose:
 *  Changes:
 */
IF ARG(1) <> '' THEN
DO
    PARSE UPPER VALUE ARG(1) WITH f_name'.TXT' o_name
    f_name = f_name'.TXT'
END
IF LENGTH( STRIP( o_name ) ) = 0 THEN
DO
    CALL CHAROUT 'STDOUT', 'Spara fil som:'
    PARSE PULL o_name
END

IF LENGTH( STRIP( f_name ) ) = 0 THEN RETURN 1
IF LENGTH( STRIP( o_name ) ) = 0 THEN RETURN 2
IF STREAM( f_name, 'C', 'QUERY EXISTS' ) = '' THEN RETURN 3
f_size = STREAM( f_name, 'C', 'QUERY SIZE' )
IF f_size < 100 THEN RETURN 4
input = CHARIN( f_name, 1, f_size )
CALL STREAM f_name, 'C', 'CLOSE'

crlf = D2C(13)D2C(10)

output = ''
DO WHILE LENGTH( input ) > 0
   IF DATATYPE( SPACE( TRANSLATE( SUBWORD( input, 1, 1 ), , '-,' ), 0 ), 'N' ) THEN
   DO
      PARSE VALUE input WITH val 20 acnt 26 dat 35 ben 56 lbl 59 cust(crlf)input
      output = output||SPACE( TRANSLATE( val,, '.' ), 0 )';'STRIP( acnt )';'STRIP( dat )';'STRIP( ben )';'STRIP( lbl )';'STRIP( cust )';'crlf
   END
   ELSE PARSE VALUE input WITH . (crlf)input
END
CALL CHAROUT STRIP( o_name ), output
CALL STREAM STRIP( o_name ), 'C', 'CLOSE'

Regards,
//Jan-Erik

15
Applications / Re: JAVA and https not possible
« on: September 05, 2016, 09:20:42 pm »
Thanks Dave and Joop,

I also read many of those instructions on the net, but just as you state have different solutions.
I did follow your advice to borrow the file from innotek java, but it was to old as it required support libraries that I couldn't find in a haste.
I ended up with cacert from another system with a recent file and it worked (111k from Aug 31, 2016).
I'm now downloading the google android sdk to this computer at the same time as I listen to music (PM123) and write this.  ;D

I also registered a new ticket #241 on netlabs https://trac.netlabs.org/java/ticket/241 that's related to this.

Regards,
//Jan-Erik

Pages: [1] 2 3 ... 10