Author Topic: architecture/substitute of cmd.exe ?  (Read 1424 times)

Martin Vieregg

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 68
    • View Profile
Re: architecture/substitute of cmd.exe ?
« Reply #15 on: October 20, 2018, 10:39:09 am »
Where can I get a documentation of the VIO APIs? How can I get the API commands from CMD/4OS2 ?

A part of the functionality can be programmed in the editor, e.g. a list of already entered commands.

Andi B.

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 20
  • Posts: 412
    • View Profile
Re: architecture/substitute of cmd.exe ?
« Reply #16 on: October 20, 2018, 12:41:52 pm »
Code: [Select]
Purpose:Create loops in batch files.

Format:DO [n | FOREVER]
    or
DO varname = start TO end [BY n ]
    or
DO [WHILE | UNTIL] condition
DO varname IN [@]set
    commands
[ITERATE]
[LEAVE]
    commands
ENDDO

varname : The environment variable that will hold the loop counter, filename, or line from a file.
n, start, end : Integers between 0 and 2,147,483,647 inclusive, or an internal variables or variable functions that evaluate to such a value.
condition : A test to determine if the loop should be executed.
set : A set of values for the variable.
commands : One or more commands to execute each time through the loop. If you use multiple commands, they must be separated by command separators or be placed on separate lines.

File Selection

Supports extended wildcards, ranges, and include lists for the set.

Usage

DO can only be used in batch files. It cannot be used in aliases.

DO can be used to create 4 different kinds of loops. The first, introduced by DO n, is a counted loop. The batch file lines between DO and ENDDO are repeated n times. For example:

        do 5
           beep
        enddo
I thought this is standard even for cmd batch processing but seems to be a 4os2 extension.

Anyway even if you don't mind about 4os2 scripts/users it's just irritating for every programmer as probably every scripting or programming language does have a command named do.

André Heldoorn

  • Sr. Member
  • ****
  • Thank You
  • -Given: 39
  • -Receive: 9
  • Posts: 432
    • View Profile
Re: architecture/substitute of cmd.exe ?
« Reply #17 on: October 20, 2018, 03:48:59 pm »
Where can I get a documentation of the VIO APIs?

That should be http://hobbes.nmsu.edu/download/pub/os2/dev/16-bit/inf16bit.zip.

One of the resouces for the screen size OS limit is the OS/2 Tookit's REXXUTIL.C (8160, i.e. 80*102, instead of 8192).

Copied & pasted sample code, just to show how to use a few of the 16-bit base OS APIs, without checking return codes:

Code: [Select]
#define INCL_NOPMAPI
#define INCL_VIO

#include <os2.h>
#include <stdio.h>
#include <string.h>

int main(void)
{
APIRET rc;
BYTE attr;
char msg[40];
int i;
VIOMODEINFO ModeData;
VIOPALSTATE vpal;

VioGetMode(&ModeData,(HVIO)0);

VioScrollUp(0,0,(USHORT)0xFFFF,(USHORT)0XFFFF,(USHORT)0xFFFF," \x7",(HVIO)0);

vpal.cb=sizeof(VIOPALSTATE);
vpal.type=0;
VioGetState(&vpal,(HVIO)0);
for (i=0;i<16;i++)
   {
   printf("%d\n",vpal.acolor[i]);
   vpal.acolor[i]=80;
   }
printf("rc=%d\n",VioSetState(&vpal,(HVIO)0));
VioSetMode(&ModeData,(HVIO)0);

attr=0;
for (i=0;i<22;i++)
   {
   sprintf(msg,"Line %2d: Programming is fun!",i);
   VioWrtCharStrAtt(msg,strlen(msg),i,i,&attr,0);
   attr+=16;
   }

VioSetCurPos(23,0,0);

return 0;
}


FWIW, I dont know what the maximum of a PMRexx window is. Perhaps 64 KiB instead of 8160.
« Last Edit: October 20, 2018, 03:53:46 pm by André Heldoorn »

RickCHodgin

  • Guest
Re: architecture/substitute of cmd.exe ?
« Reply #18 on: November 02, 2018, 04:06:50 pm »
Code: [Select]
#define INCL_NOPMAPI
#define INCL_VIO

#include <os2.h>
#include <stdio.h>
#include <string.h>

int main(void)
{
APIRET rc;
BYTE attr;
char msg[40];
int i;
VIOMODEINFO ModeData;
VIOPALSTATE vpal;

VioGetMode(&ModeData,(HVIO)0);

VioScrollUp(0,0,(USHORT)0xFFFF,(USHORT)0XFFFF,(USHORT)0xFFFF," \x7",(HVIO)0);

vpal.cb=sizeof(VIOPALSTATE);
vpal.type=0;
VioGetState(&vpal,(HVIO)0);
for (i=0;i<16;i++)
   {
   printf("%d\n",vpal.acolor[i]);
   vpal.acolor[i]=80;
   }
printf("rc=%d\n",VioSetState(&vpal,(HVIO)0));
VioSetMode(&ModeData,(HVIO)0);

attr=0;
for (i=0;i<22;i++)
   {
   sprintf(msg,"Line %2d: Programming is fun!",i);
   VioWrtCharStrAtt(msg,strlen(msg),i,i,&attr,0);
   attr+=16;
   }

VioSetCurPos(23,0,0);

return 0;
}


I code this in Borland C++ and it compiles fine, runs fine, but doesn't do anything.  When I single-step into it I don't get a console window to look at the output.  It does step through each line, however.

Also, on the VioWrtCharStrAtt(msg, strlen(msg), i, i, &attr, 0); line, the sprintf() function returns information that can be utilized:

Code: [Select]
int len = sprintf(msg,"Line %2d: Programming is fun!",i);
VioWrtCharStrAtt(msg,len,i,i,&attr,0);

It increases performance ... slightly. :-)

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 9
  • -Receive: 129
  • Posts: 1862
    • View Profile
Re: architecture/substitute of cmd.exe ?
« Reply #19 on: November 02, 2018, 04:20:06 pm »
Might need a def file to go along with it. The important part would be
Code: [Select]
NAME    TEST   NOTWINDOWCOMPATassuming your program is named test.exe.

RickCHodgin

  • Guest
Re: architecture/substitute of cmd.exe ?
« Reply #20 on: November 02, 2018, 04:28:08 pm »
Might need a def file to go along with it. The important part would be
Code: [Select]
NAME    TEST   NOTWINDOWCOMPATassuming your program is named test.exe.

Well it was even simpler.  It had a target of PM.EXE rather than CMD.EXE.  Switching that fixed it.