OS/2, eCS & ArcaOS - Technical > Utilities
architecture/substitute of cmd.exe ?
Martin Vieregg:
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.:
--- Code: ---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
--- End code ---
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:
--- Quote from: Martin Vieregg on October 20, 2018, 10:39:09 am ---Where can I get a documentation of the VIO APIs?
--- End quote ---
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: ---#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;
}
--- End code ---
FWIW, I dont know what the maximum of a PMRexx window is. Perhaps 64 KiB instead of 8160.
RickCHodgin:
--- Quote from: André Heldoorn on October 20, 2018, 03:48:59 pm ---
--- Code: ---#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;
}
--- End code ---
--- End quote ---
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: ---int len = sprintf(msg,"Line %2d: Programming is fun!",i);
VioWrtCharStrAtt(msg,len,i,i,&attr,0);
--- End code ---
It increases performance ... slightly. :-)
Dave Yeo:
Might need a def file to go along with it. The important part would be
--- Code: ---NAME TEST NOTWINDOWCOMPAT
--- End code ---
assuming your program is named test.exe.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version