OS2.org Site Index - Feedback - Impressum
Sprachauswahl / Choose your Language News Software Hardware Projekte Forum Tipps Links Verschiedenes
Editorial Diskussion HelpDesk Umfrage
[Forum]
in nach (Erweiterte Suche)
[Forum]
( 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 ]

Datum Thema
07.01.2017 *

*

Name: * eMail: Benachrichtigung

Mit * markierte Felder müssen ausgefüllt werden !

( Zeige alle Einträge ) ( Zur Startübersicht )
Thema von: Leser Datum Zeit
 Objektklasse mit REXX?
Andreas Schnellbacher13328.07.200018:03
 z.B. mit zwei Funktionen
GA12129.07.200013:51
 Re: z.B. mit zwei Funktionen
Andreas Schnellbacher10729.07.200019:11
 Zur Subklasse WPDataFile
GA10130.07.200014:50
 Ein Beispiel zu SysSetObjectData
GA9730.07.200018:55
 Ändern mit SysCreateObject
GA9031.07.200014:33
 Klasse mit SysPutEA aendern?
Andreas Schnellbacher8501.08.200013:27
 Nochmals: Mit SysCreateObject Paramter ändern!
GA9102.08.200008:40
 Re: Nochmals: Mit SysCreateObject Paramter ändern!
Andreas Schnellbacher7106.08.200015:37
 CLASSDEFAULTVIEW --- ein "neuer" Setup-String
Andreas Schnellbacher7106.08.200015:39
 Weitere Annahmen
GA6806.08.200016:33
 Weiterer Hinweis(I)
GA6406.08.200016:43
 Eine REXX-Routine mit der UDATE-Option mit...
GA6806.08.200016:58
 Protokoll der Routine EADUMP
GA6808.08.200011:35
 Extended Attributes mit REXX lesen und setzen
GA5803.09.200017:47
 Objektklasse A E N D E R N geht nicht mit SysCreateObjekt!
Andreas Schnellbacher5503.09.200019:29
 Re: Objektklasse A E N D E R N geht nicht mit SysCreateObjekt!
Peter W.5311.09.200009:50
 Mit SysCreateObjekt nur bestimmte Argumente..
GA4711.09.200012:24
 Re: Mit SysCreateObjekt nur bestimmte Argumente..
Sebastian Wittmeier4711.09.200017:35
 Re:
Andreas Schnellbacher4113.09.200020:37
 So geht's
Andreas Schnellbacher3406.05.200100:52
 Ja, wunderbar, Andreas!
GA2906.05.200114:38
 Re: Ja, wunderbar, Andreas!
Andreas Schnellbacher2506.05.200118:07


php.net OpenIT © 1998-2017 by WebTeam OS2.org