File Attributes

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

File Attributes

Post by Patz QuickBASIC Creations »

It would be nice if BASIC had an easy way of changing them, but so far I don't see one. So, does anyone have an easy way of checking and setting various attributes like HIDDEN, READ-ONLY, SYSTEM, etc.?
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Do you want to see or change file attributes from within a QB program? If so, you have a problem. I've only been able to do this by linking with the QuickPak Professional Library and it's functions.

If you only need to do this from the DOS commandline, you can use the following utilities:
1) ATTRIB utility which comes with DOS. A bit clunky, but it might serve your purpose. Do ATTRIB /? for instructions.

2) FA utility program from the Norton Utilities. You may be able to still find it around.

3) !ATTR utility which I wrote. I can send it to your email address.

Even with the library functions, it's not that easy. I takes about 300 lines of QB code to do it right.

Regards..... Moneo
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

Well, then I guess I have a problem :P

I know Plasma made a routine for checking for HIDDEN files and such, which he dubbed DIR2$, as (you guessed it) a replacement for DIR$.

But, yes. What you described is exactly what I need to do. Load the attributes into some sort of variable (I'm flexible) and be able to change them and write them back to the file. Maybe I'll find a way to shell to ATTRIB or something. Sure, send !ATTR to my email, patzbasic [AT] gmail.com

Thanks for your input.
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Patz,
No sense in sending my !ATTR utility. I just compared mine to DOS's ATTRIB, and they are virtually the same. Mine generates an errorlevel that can be tested from within a batchfile, in case there was some anomaly, like file doesn't exist, illegal attribute, like trying to set a directory to Read Only, etc. I figure you don't need any of this.

Yes, try doing a shell to ATTRIB. Should work. Let me know.

If you later figure out that you'd like !ATTR, let me know and I'll send it.

Regards..... Moneo
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

I looked into it some more (the computers I can use for internet are blocked against DOS), and ATTRIB's output seems straight forward, and easy to manipulate. Shouldn't be too hard to shell to it.

Yeah, I'll post more once I do more. Been lazy for the last week :P
Master-of-Mischief
Coder
Posts: 14
Joined: Thu Aug 02, 2007 8:53 pm
Location: USA

Post by Master-of-Mischief »

An easy way to change attributes, well first let me ask, are you familiar with changing attributes with interrupts?
Post Reply