home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / OBJSET.CMD < prev    next >
OS/2 REXX Batch file  |  1995-03-27  |  7KB  |  194 lines

  1. EXTPROC CEnvi2
  2. //***************************************************************
  3. //*** ObjSet.cmd - Set value for an object, such as making an ***
  4. //*** ver.2        object non-deletable                       ***
  5. //***************************************************************
  6.  
  7. #include <PMdll.lib>
  8. #include <Profile.lib>
  9.  
  10. main(argc,argv)
  11. {
  12.    if ( 2 == argc  &&  !stricmp(argv[1],"MANUAL") ) {
  13.       Manual();
  14.       return EXIT_FAILURE;
  15.    }
  16.    if ( 3 != argc ) {
  17.       Instructions();
  18.       return EXIT_FAILURE;
  19.    }
  20.  
  21.    ObjectName = argv[1];
  22.    ObjectSetting = argv[2];
  23.  
  24.    ObjectID = GetObjectID(ObjectName);
  25.    if ( !ObjectID ) {
  26.       printf("Could not locate object \"%s\".\a\n",ObjectName);
  27.       return EXIT_FAILURE;
  28.    }
  29.  
  30.    strcat(ObjectSetting,";");
  31.    if ( !WinSetObjectData(ObjectID,ObjectSetting) ) {
  32.       printf("Setting \"%s\" failed for object.\n",ObjectSetting);
  33.       return EXIT_FAILURE;
  34.    }
  35.  
  36.    return EXIT_SUCCESS;
  37. }
  38.  
  39. GetObjectID(pObjectName) // return Object ID, or 0 if not found
  40. {
  41.    if ( !(lObjectID = WinQueryObject(pObjectName)) )
  42.       lObjectID = FindWPSProgramObject(pObjectName);
  43.    return lObjectID;
  44. }
  45.  
  46. FindWPSProgramObject(pObjectSpec)
  47.    // assume this is an object in a folder, but not a real object, and
  48.    // so search the OS2.INI file for information to get this object
  49. {
  50.    // separate folder from object, if no folder then assume desktop
  51.    lFileParts = SplitFileName(pObjectSpec);
  52.    lFolderName = lFileParts.dir;
  53.    if ( !lFolderName[0] ) {
  54.       // no folder spec, so use desktop
  55.       lFolderID = 0xFFFF & WinQueryObject("<WP_DESKTOP>");
  56.    } else {
  57.       if ( '\\' == lFolderName[(lLen = strlen(lFolderName))-1] )
  58.          lFolderName[--lLen] = 0;
  59.       lFolderID = 0xFFFF & WinQueryObject(lFolderName);
  60.    }
  61.    if ( lFolderID ) {
  62.  
  63.       // create buffer that is the string to search objects for
  64.       sprintf(lObjectName,"%s%s",lFileParts.name,lFileParts.ext);
  65.       lMatchBufLen = 2 + strlen(lObjectName) + 1;
  66.       BLObPut(lMatchBuf,0,lMatchBufLen-2,UWORD16);
  67.       BLObPut(lMatchBuf,2,lObjectName,lMatchBufLen-2);
  68.  
  69.       // Find this folder in OS2.INI under PM_Abstract:FldrContent
  70.       sprintf(lKey,"%X",lFolderID);
  71.       BLObSize(lData,lDataSize=4000);
  72.       if ( PrfQueryProfileData(HINI_USERPROFILE,"PM_Abstract:FldrContent",lKey,
  73.                                lData,lDataSize) ) {
  74.          // try on each object within this folder
  75.          for ( lOffset = 0; lOffset < lDataSize; lOffset += 4 ) {
  76.             lObjectID = BLObGet(lData,lOffset,UWORD32);
  77.             // try to find this object ID within PM_Abstract:Objects
  78.             sprintf(lKey,"%X",lObjectID);
  79.             BLObSize(lObjData,lObjDataSize=4000);
  80.             if ( PrfQueryProfileData(HINI_USERPROFILE,"PM_Abstract:Objects",lKey,
  81.                                      lObjData,lObjDataSize) ) {
  82.                while ( 0 < lObjDataSize
  83.                     && NULL != (lFindData=memchr(lObjData,lMatchBuf[0],lObjDataSize)) ) {
  84.                   if ( !memicmp(lFindData,lMatchBuf,lMatchBufLen) )
  85.                      // YEA! FINALLY THE OBJECT WAS FOUND
  86.                      return( 0x20000 | lObjectID );
  87.                   lDataSkip = lFindData - lObjData + 1;
  88.                   lObjDataSize -= lDataSkip;
  89.                   lObjData += lDataSkip;
  90.                }
  91.             }
  92.          }
  93.       }
  94.    }
  95.    return(NULL);
  96. }
  97.  
  98. Instructions()
  99. {
  100.    puts("\a")
  101.    puts(`ObjSet - Alter settings for WPS objects`)
  102.    puts(``)
  103.    puts(`USAGE: ObjSet [<ObjectID> <Setting>] | [MANUAL]`)
  104.    puts(``)
  105.    puts(`WHERE: ObjectID - Object ID of an existing program object or fully qualified`)
  106.    puts(`                  filename or directory ( e.g., <WP_DESKTOP>,`)
  107.    puts(`                  E:\Utl\MyProg.exe, "C:\Desktop\DOS Window"`)
  108.    puts(`       Setting - String containing the setting to apply to this object`)
  109.    puts(`       MANUAL - Enter this option for a longer manual describing some of the`)
  110.    puts(`                objects and settings.`)
  111.    puts(``)
  112. }
  113.  
  114. Manual()
  115. {
  116.  Instructions();
  117.  puts(``)
  118.  puts(`ObjectID may be the exact location (directory and object or file/folder`)
  119.  puts(`specification).  If no folder (directory) is supplied then the desktop is`)
  120.  puts(`assumed.  Keep in mind that the true name of directories is not always the`)
  121.  puts(`name you seen in the WPS.`)
  122.  puts(``)
  123.  puts(`There are many predifined object ID's.  These all begin with '<' and end with`)
  124.  puts(`'>'.  Some examples are "<WP_DESKTOP>", "<WP_START>", and "<WP_NOWHERE>".  For`)
  125.  puts(`a full list of predefined object ID's, enter the following command:`)
  126.  puts(`   DumpIni OS2 PM_Workplace:Location`)
  127.  puts(``)
  128.  puts(``)
  129.  puts(`There are very many settings strings that can be applied to objects.  Not all`)
  130.  puts(`objects understand all settings types.  Here are usefule settings to know:`)
  131.  puts(``)
  132.  puts(`   NOCOPY=YES           this and following NOxxx can be set to NO`)
  133.  puts(`   NODELETE=YES`)
  134.  puts(`   NODRAG=YES`)
  135.  puts(`   NOLINK=YES`)
  136.  puts(`   NOMOVE=YES`)
  137.  puts(`   NOPRINT=YES`)
  138.  puts(`   NORENAME=YES`)
  139.  puts(`   NOSHADOW=YES`)
  140.  puts(`   NOTVISIBLE=YES`)
  141.  puts(`   ALWAYSSORT=YES`)
  142.  puts(``)
  143.  puts(`   OBJECTID=<NAME>      Give object object name alias`)
  144.  puts(``)
  145.  puts(`   OPEN=DEFAULT         open default view; open now`)
  146.  puts(`   OPEN=SETTINGS        open settings notebook`)
  147.  puts(``)
  148.  puts(`   OPEN=DETAILS`)
  149.  puts(`   OPEN=ICON`)
  150.  puts(`   OPEN=TREE`)
  151.  puts(``)
  152.  puts(` folder views can have the following settings`)
  153.  puts(`   DETAILSVIEW=setting1,setting2,setting3...`)
  154.  puts(`   ICONVIEW=setting1,setting2,setting3...`)
  155.  puts(`   TREEVIEW=setting1,setting2,setting3...`)
  156.  puts(` where the settings may be any of the following:`)
  157.  puts(`   FLOWED`)
  158.  puts(`   NONFLOWED`)
  159.  puts(`   NONGRID`)
  160.  puts(`   NORMAL`)
  161.  puts(`   MINI`)
  162.  puts(`   INVISIBLE`)
  163.  puts(`   LINES`)
  164.  puts(`   NOLINES`)
  165.  puts(``)
  166.  puts(`   BACKGROUND=FileSpec  specify file name for background image`)
  167.  puts(`   WORKAREA=YES         can set NO`)
  168.  puts(`   MINWIN=HIDE          minimized view, may also be VIEWER or DESKTOP`)
  169.  puts(`   VIEWBUTTON=HIDE      hide button, may also be MINIMIZE`)
  170.  puts(`   CONCURRENTVIEW=YES   create new views when opened; may also be NO`)
  171.  puts(`   TEMPLATE=YES         object is template; else NO`)
  172.  puts(``)
  173.  puts(`   ICONFILE=FileSpec`)
  174.  puts(`   ICONRESOURCE=id,module`)
  175.  puts(`   ICONPOS=x,y          Initial icon position in folder`)
  176.  puts(``)
  177.  puts(` program object settings; in addition to DOS settings`)
  178.  puts(`   PROGTYPE=FULLSCREEN  sesion type, may also be PM, SEPARATEWIN, VDM, WIN`)
  179.  puts(`                        WINDOWABLEVIO, WINDOWEDVDM, WINDOWEDWIN`)
  180.  puts(`   MINIMIZED=YES        may be NO`)
  181.  puts(`   MAXIMIZED=YES        may be NO`)
  182.  puts(`   NOAUTOCLOSE=YES      may be NO`)
  183.  puts(``)
  184.  puts(`   ASSOCFILTER=filter1,filter2,filter3,...`)
  185.  puts(`   ASSOCTYPE=type1,type2,type3,...`)
  186.  puts(``)
  187.  puts(` EXAMPLES:`)
  188.  puts(`   ObjSet C:\OS2 ICONVIEW=NONFLOWED,NORMAL;OPEN=ICON`)
  189.  puts(`   ObjSet "<WP_SYSTEM>" MINWIN=HIDE;OPEN=DEFAULT`)
  190.  puts(`   ObjSet "C:\Desktop\OS/2 Window" NODELETE=YES`)
  191.  puts(`   ObjSet "D:\MyDir\MyProgram" "OBJECTID=<MY_PROGRAM>"`)
  192. }
  193.  
  194.