04.01.2013 Views

Amiga Computing - Commodore Is Awesome

Amiga Computing - Commodore Is Awesome

Amiga Computing - Commodore Is Awesome

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Paul Overaa<br />

starts work on<br />

a date<br />

stamping utility<br />

Over the next two months I'm going to<br />

turn the skeleton code provided on the<br />

February coverdisk (or on our Web site)<br />

^^^B into a utility that will run in Workbench<br />

that can extract date stamps (in ASCII form) from<br />

all files in a given directory. There are plenty of uses<br />

for such a program but the one I have in mind is<br />

one which will allow easy date stamping of Web<br />

pages.<br />

If, for example, you check out my corner of<br />

<strong>Amiga</strong> <strong>Computing</strong>'s Web site you will see all pages<br />

have a last updated date stamp in them. These<br />

dates are in fact generated automatically by a utility<br />

currently written in C, but I thought a directly coded<br />

680x0 version might be useful for the purposes of<br />

this column because, once you've seen the ideas<br />

involved, you'll realise that the same framework<br />

can be used to create many other utilities.<br />

The starting point for the discussions is the<br />

DirHandler() routine whose main job at the<br />

moment (if we disregard the temporary print/clear<br />

name operations) is to copy the selected directory<br />

name from the asl requester. Copying is usually<br />

done so a selected filename can be added to a<br />

directory to produce a complete path for the file.<br />

For our current application however, being only<br />

interested in drawer names, we can eliminate the<br />

copying and use the asl requester's own directory<br />

buffer. This approach involves some minor changes<br />

in that the text pointers of the intuiText structures<br />

cannot now be defined using the original static<br />

dimame reference.<br />

Instead we install the pointers at run time (after<br />

the internal asi buffers have been allocated). The<br />

new method, which you'll find in my AllocFileReqO<br />

routine, is to load aO with the asl requester base<br />

and load ai with each IntuiText base in turn to<br />

copy the pointers using indirect addressing instruc<br />

tions like this:<br />

■0«.l frJrauer(aO),it_lTeJt(a1)<br />

These and a few other minor alterations - such as<br />

adding an image to the display using the Intuition<br />

Drawlmage() function and changing the window<br />

and menu text - will be easy enough to recognise<br />

by comparing this month's source with that from<br />

the previous issue. The real work however, involves<br />

extending the DirHandlerO routine so it can search<br />

the named directory and locate any files present.<br />

Dos Operations<br />

Once a directory name is available the directory<br />

must be locked using the Dos library LockO func<br />

tion. An FIB (File Info Block) must also be allocated<br />

using AlIocDosObject() and it's initial directory val<br />

ues set by calling Examine(). An ExNextO loop can<br />

then be used to examine all the files in the select<br />

ed directory.<br />

The easiest way to explain the relationship<br />

<strong>Amiga</strong> <strong>Computing</strong><br />

MARCH 1997<br />

DirHandler<br />

.deallocate<br />

.t»it<br />

rts<br />

StampOnIT!<br />

movem.l<br />

lea<br />

tfO-d5/iO-a2/a5,-

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!