OS/2, eCS & ArcaOS - Technical > Programming

REXX tutorials -- start developing applets under ArcaOS out-of-the-box

<< < (2/6) > >>

Lewis Rosenthal:
I could see Arca Noae providing a WarpIN package via the repository which would install a collection of REXX books and code snippets, which would be shadowed/created in the Development folder. Likewise, I could see similar packages for OREXX, Regina, PHP, Python, Perl, etc.

We could also consider adding a number of useful links to the Websites folder (currently "Web Sites," but slated to be renamed to something more contemporary - at least in English). This is an underused resource on the desktop the use of which we could also promote better.

From Arca Noae's perspective, adding more content to the ISO itself is the least desirable option for things which could be installed after-the-fact and kept updated between ISO releases.

Alfredo Fernández Díaz:
Hi Dariusz, Steven, Jan-Erik, Dave, Lewis -- that's the idea!

Well, so for the moment being and me cRexx it is, as it is available for everyone by default, and I expect by the time any advantages of (o)oRexx become a necessity for people, they should be able to simply switch from tutorials to reference manuals -- mind you, of course any comments on how 'the same can be done with less --or otherwise better-- (o)orexx code like this' are most welcome!

As Dariusz pointed out, it is always an excellent idea to have a bibliography covering any subject at hand in depth, either in the form of the books themselves if available, or at least a list, so thank you for that. However, I think the best tutorials, while referring to appropriate materials where everything is covered in full, do at the same time keep their own stuff at a minimum to ensure everything can be grasped in one go.

Every year I find myself having to match syllabi/syllabuses which are impossibly broad and deep to the corresponding exams, so you see where I come from. Rather than going for the mechanical 'recipes for exercises' approach, every year I have a(nother) go at condensing (butchering, really) each subject in such a way that students will stand some chance to do well at their exams while it still makes sense as a whole for those who really want to understand -- with any luck, I'll have enabled some to pick up a book and make sense of the real stuff when laid out in proper depth. I like to think I slowly get better at it, so let's see what we can do here... ; )

Alfredo Fernández Díaz:
I imagine we can start with something rather basic and see if can give this some shape so it is useful for those who might find the relevant parts of the crexx reference overwhelming or otherwise unappealing.

The following procedure


--- Code: ---/**/
parse arg where
call lineout where,'     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5'
do i=1 to 15
  call charout where,' '||right(i*16,3,' ')
  do j=0 to 15
    call charout where,' '||d2c(i*16+j)
  end
  call lineout where,' '||right(16*i+15,3,' ')
 end
call lineout where,'     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5'
call lineout where
exit
--- End code ---

will print out the following ASCII table:

     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
  16                  31
  32   ! " # $ % & ' ( ) * + , - . /  47
  48 0 1 2 3 4 5 6 7 8 9 : ; < = > ?  63
  64 @ A B C D E F G H I J K L M N O  79
  80 P Q R S T U V W X Y Z [ \ ] ^ _  95
  96 ` a b c d e f g h i j k l m n o 111
 112 p q r s t u v w x y z { | } ~  127
 128 Ç ü é â ä à å ç ê ë è ï î ì Ä Å 143
 144 É æ Æ ô ö ò û ù ÿ Ö Ü ø £ Ø × ƒ 159
 160 á í ó ú ñ Ñ ª º ¿ ® ¬ ½ ¼ ¡ « » 175
 176 ░ ▒ ▓ │ ┤ Á Â À © ╣ ║ ╗ ╝ ¢ ¥ ┐ 191
 192 └ ┴ ┬ ├ ─ ┼ ã Ã ╚ ╔ ╩ ╦ ╠ ═ ╬ ¤ 207
 208 ð Ð Ê Ë È € Í Î Ï ┘ ┌ █ ▄ ¦ Ì ▀ 223
 224 Ó ß Ô Ò õ Õ µ þ Þ Ú Û Ù ý Ý ¯ ´ 239
 240 ­ ± ‗ ¾ ¶ § ÷ ¸ ° ¨ · ¹ ³ ² ■   255
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5

Notes (before you tackle the full rexx reference):
-The procedure can print to a file using the filename as a parameter. If omitted (empty), the table will be printed to screen. Individual instructions "charout" and "lineout" do the same.
-Characters are produced sequentially according to their codepoint number because there is a simple way to convert numbers to characters. Check "d2c".
-Initial and final reference values are padded on the left to take up 3 spaces and stay aligned on the right. Check "right".
-The actual characters shown depend on system codepage. Try this on a separate session after the command "CHCP <secondary codepage>", and compare.
-Should it be mentioned that the two nested loops for rows and individual cells within each row need two different indices, but that these can be used separately and together (e.g. to calculate the code for each current char)?

As you see, the idea is that we take some simple task (for the level considered), complete it with a minimal set of basic instructions, and comment on some aspects that being interesting can be easily overlooked when reading a full reference. Rinse and repeat with more advanced stuff.

Does this look any good to you? What would you improve? Post your own, better examples ; )

Edit: tt -> code

Jan-Erik Lärka:

--- Quote from: Alfredo Fernández Díaz on February 22, 2025, 11:01:58 pm ---/**/
parse arg where
call lineout where,'     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5'
do i=1 to 15
  call charout where,' '||right(i*16,3,' ')
  do j=0 to 15
    call charout where,' '||d2c(i*16+j)
  end
  call lineout where,' '||right(16*i+15,3,' ')
 end
call lineout where,'     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5'
call lineout where
exit

--- End quote ---

It is often just a matter of personal taste and preference, so the code to output that can be written in many ways and they'll serve well, thus cause frustration and confusion for beginners that want one and only one solution to cling to.

But here goes, assuming that the code has been saved to "charcode.cmd":
parse arg where and every occurance of where can be omitted in this case, as one can type "charcode > c850.txt" to save it to file c850.txt

How about a loop for:
call lineout ,'     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5'
such as:
do i = 0 to 15 /* loop 16 times, start at 0 and end at 15 */
  call charout , right( i, 2 + 4 * ( i = 0 ) , ' ' ) /* output a number, with 1 space in front and 4 more if loop number is zero*/
End
SAY /* This "say" without anything else just add a new line character */

Gordon Snider:
Sorry if I'm not doing this right.  I am a very infrequent contributor  and am still learning the ropes.

The code below is for anyone who wants to visit all directories, one by one, below the current directory
as root,  out to the "leafs".  It makes use of recursion inside a loop.  It actually visits each directory
twice, once on the "head" recursion and again on the way back in,  "tail" recursion.

It assumes RexxUtil.DLL HAS ALREADY BEEN LOADED.  (I load it at boot time.)
   
You can find lots of nooks and crannies to put features in. 


/* KERNEL          CMD by Gord Snider  v1.0                                  */
current = Strip( Directory(), 'T', '\')         /* save fully qualified current directory for return */
SAY current                                     /* say current directory */
CALL next current                               /* call to check for sub-directories */
EXIT 0

next: PROCEDURE                                 /* hide old set of variables, enable new set */
PARSE ARG nextdir,spacer                        /* spacer is each line's indenting characters */
CALL SysFileTree Strip( nextdir, 'T', '\') || '\' || '*', 'dir.', 'DO'  /* are subfolders here? */
DO dir = 1 TO dir.0                             /* if any, make a list of them and process it */
   IF dir < dir.0 THEN leader = D2C(195)
                  ELSE leader = D2C(192)
  SAY spacer || ' ' || leader || SUBSTR( dir.dir, LASTPOS('\', dir.dir) + 1)
  IF leader = D2C(195) THEN leader = D2C(179)
                       ELSE leader = ' '
  CALL next dir.dir, spacer || ' ' || leader    /* pivot point of the recursion */
END dir                                         /* back to top of dir loop */
RETURN                                          /* a leaf has been reached */

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version