TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Henk den Adel
from: Peter Fitzsimmons
date: 1995-03-19 21:36:04
subject: Task list

HdA>   printf("%s\n", *pswblk.aswentry.swctl.szSwtitle);

Your problem is that a few of those '.'s should be '->'.  Without
debuging your code in detail,  let me just give you a program I wrote long
ago.

It is a 16bit command-line program that is intended to switch to a session
by name;  but when you run it with no arguments it lists the current
programs -- which is what you want,  right?

 #include 
 #include 
 #include 
 #define INCL_WIN
 #define INCL_WINSWITCHLIST
 #include 

 /*
  * GT.C (goto session)
  *
  * This program switches to a session by name,  or lists the titles of
  * all currently running sessions.
  *
  * Usage: GT
  *        lists current tasks.
  *
  * Usage: GT 
  *        Switches to first task that has  anywhere in its name.
  *
  *
  * MSC 6.00 (5.10 prob ok),  memory model indep.
  *
  * P. Fitzsimmons. 01:20:05 Mon  07-02-1990
  */

 void cdecl main(int argc, char **argv)
 {
     USHORT num,i;
     SWBLOCK *pSwb;

     if(argc>1)
         strupr(argv[1]);
     num = WinQuerySwitchList(0L, NULL, 0);
     if(!num){
         puts("Unexpected error");
         return;
     }
     pSwb = malloc(sizeof(HSWITCH) + sizeof(SWENTRY) * num );
     num = WinQuerySwitchList(0L, pSwb,
                                  sizeof(HSWITCH) + sizeof(SWENTRY) * num );
     if(argc==1)
         printf("PID  Task Title\n---------------\n");
     for(i=0; iaswentry[i].swctl.idProcess,
                                 pSwb->aswentry[i].swctl.szSwtitle);
         else if( strstr(strupr(pSwb->aswentry[i].swctl.szSwtitle), argv[1])){
             printf("Switching to '%s'\n",
pSwb->aswentry[i].swctl.szSwtitle);
             WinSwitchToProgram(pSwb->aswentry[i].hswitch);
             break;
         }
     }
     free(pSwb);
     if(argc==1){
         printf("\nTo switch to a program,  type '%s '\n", argv[0]);
     }
     else if(i==num){
         printf("'%s' could not be found in any of the task titles!\n",
                argv[1]);
     }
 }

I just tried compiling it with Cset++,  and it worked without warning.

--- Maximus/2 2.02p1
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)
SEEN-BY: 105/42 620/243 624/50 711/401 409 410 413 430 807 808 809 934 955
SEEN-BY: 712/407 515 628 704 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/702 3615/50 396/1 270/101 105/103 42 712/515
@PATH: 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.