Site Index - Feedback - Impressum |
| |||||||||
|
|
( Archiv ) | ( Neues Thema ) |
03.09.2000 |
Extended Attributes mit REXX lesen und setzen (von: GA, 17:47:56) | « ^ » |
V.CMD - Saving Extended Attributes with REXX
After putting together this code I got the idea that perhaps folks might be interested in having a monthly learning REXX article in the Newsletter. To that end starting next month see this space for Beginning with OS/2 REXX. Below is a piece of REXX code that I (literally) threw together in about half an hour. The concept behind this code is simple: I needed to keep track of what changes I had made to various files as part of a project. Of course, with most files you can't just add a chunk of text at the top and still have them useful for their intended purpose (ie: Binary files, WP/AmiPro documents, WAV files, etc.) so I had to have another way of saving data along with the file itself. Guess what? OS/2 does just this function with EXTENDED ATTRIBUTES. Under the FAT file system OS/2 saves the Attributes in that irritating file EA_DATA._SF. Under HPFS the Attributes are saved with the file. In both cases the way that we create and modify these Attributes is the same. The REXX additional function library (REXXUTIL.DLL) that is included with OS/2 (and documented in the Online REXX manual) gives us this special function. Using the functions called SysGetEA and SysPutEA we have the ability to place and retrieve EXTENDED ATTRIBUTES to any object in OS/2. The code below uses these functions within a wrapper of REXX to add additional function to our Editor of choice. By passing one of the parameters to the program we can CREATE, ADD to, DELETE or VIEW any comments to file we edit. In fact we can even modify the comments without even editting the file. In this example we simply add an EA called VERLOG (because I was using the EA's to track Versions of my files) and use that to hold our comments. For your own use you can use this EA, or additional EA's to store ANY information you want with a file. You can save comments, the name of the updater, the name of the editor used to edit the file or any other information you want to keep track of. Just save this HTML Page to a file called V.CMD, remove anything above AND below the first and last REXX comments (the /***....***/ lines) and save the file. The file is also part of this month's Shareware Disk. You should have 127 lines in the final file and the first line must be the first REXX comment line. Type V and the program should show you it's own help screen. /********************************************************************OS2*REXX*/ /* V.CMD */ /* */ /* 960224 - Terry Hamilton - TCH Consulting Services */ /* */ /* Function: Allows adding of Comments to a file as an EXTENDED ATTRIBUTE */ /* (can also add comments to a Directory by using only /a!) */ /* */ /* Operation: Simply type "V filename" to edit a file */ /* After edit you will be prompted for a comment */ /* Null (blank) comments are ignored */ /* Type V /? for detailed commands */ /* I use it to add version/change info to my files. */ /* */ /* Requires: REXXUTIL.DLL in the Libpath (as per a regular OS/2 install) */ /* */ /* Customize: To use a specific EDITOR change the EDITOR variable below */ /* You could easily modify to select editor based on extension */ /* */ /* Copyright: None. Free for use by anyone and everyone. */ /* No Warranties express or implied. Use at your own risk. */ /*****************************************************************************/ /* Edit this line to specify your favoriate editor */ EDITOR = "TEDIT.EXE" /* Load REXXUTIL functions (to access the EA's) */ call rxfuncadd "sysloadfuncs", "rexxutil", "sysloadfuncs" call sysloadfuncs /* Get command line parameters */ parse arg fname comment /* Decide how to handle the file */ select /* User asked for help */ when fname = "/?' then do say; say say "Utility to add EA Comments to a file." say " If you type:" say " V filename " say " you will edit the file with "EDITOR" and the V.CMD" say " will ask for a comment to add to the file EA's." say say " Parameters:" say say " V fname commenttext - edit and add these comments" say " V fname /s - SHOW current comments" say " V fname /a - ADD a comment without editting" say " V fname /K - KILL (delete) all comments (Capital K!)" say " V fname /n - edit without prompting for comments" say " V /? - this HELP screen" say say " Example:" say " V config.sys Increasing SWAPPER size" say " Edit CONFIG.SYS adding this comment to the EA's" say " V config.sys /s" say " Show the comments I have for CONFIG.SYS" end /* SHOW EA's */ when comment = "/s' then do rc = SysGETEA(fname,"VERLOG","VAR") do until pos(D2C(1),var)=0 parse value var with line '' var say line end say var if var='' then say "No Comments" end /* KILL (delete) any EA's (Case SENSITIVE!) */ when comment = "/K' then do rc = SysPUTEA(fname,"VERLOG","") say; say 'Comments deleted' end /* Edit without adding a comment */ when comment = "/n' then '@'EDITOR fname /* Add a comment and DON'T EDIT */ when comment = "/a' then do say "Enter Comment:" parse pull comment call addcomm end /* Edit then prompt for a comment */ when comment = '' then do '@'EDITOR fname say say "Enter Comment:" parse pull comment call addcomm end /* User supplied a comment on initial command line */ otherwise do '@'EDITOR fname call addcomm end end /* Single exit point */ Exit /* If comment isn't blank append it to the VERLOG EA */ addcomm: if comment<>'' then do rc = SysGETEA(fname,"VERLOG","VAR") comment = var||D2C(1)||date('O') time()" - "comment rc = SysPUTEA(fname,"VERLOG",comment) end return /*****************************************************************************/ Click here to return. [ Leser: 58 ] |
|
Mit * markierte Felder müssen ausgefüllt werden ! |
( Zeige alle Einträge ) | ( Zur Startübersicht ) |
|
| Andreas Schnellbacher | 133 | 28.07.2000 | 18:03 |
| GA | 121 | 29.07.2000 | 13:51 |
| Andreas Schnellbacher | 107 | 29.07.2000 | 19:11 |
| GA | 101 | 30.07.2000 | 14:50 |
| GA | 97 | 30.07.2000 | 18:55 |
| GA | 90 | 31.07.2000 | 14:33 |
| Andreas Schnellbacher | 85 | 01.08.2000 | 13:27 |
| GA | 91 | 02.08.2000 | 08:40 |
| Andreas Schnellbacher | 71 | 06.08.2000 | 15:37 |
| Andreas Schnellbacher | 71 | 06.08.2000 | 15:39 |
| GA | 68 | 06.08.2000 | 16:33 |
| GA | 64 | 06.08.2000 | 16:43 |
| GA | 68 | 06.08.2000 | 16:58 |
| GA | 68 | 08.08.2000 | 11:35 |
| GA | 58 | 03.09.2000 | 17:47 |
| Andreas Schnellbacher | 55 | 03.09.2000 | 19:29 |
| Peter W. | 53 | 11.09.2000 | 09:50 |
| GA | 47 | 11.09.2000 | 12:24 |
| Sebastian Wittmeier | 47 | 11.09.2000 | 17:35 |
| Andreas Schnellbacher | 41 | 13.09.2000 | 20:37 |
| Andreas Schnellbacher | 34 | 06.05.2001 | 00:52 |
| GA | 29 | 06.05.2001 | 14:38 |
| Andreas Schnellbacher | 25 | 06.05.2001 | 18:07 |
|