Normal Topic external file input output functions and commands (Read 973 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
external file input output functions and commands
May 7th, 2004 at 7:09pm
Print Post Print Post  
Is there some reason that the fileread and fileseek commands do not work with files stored on a cd? I know I can not write to the cd but I thought as long as I have read attributes my fileread and fileseek should work.

I created a command button that I was using to practice my external file input output functions and commands.

The goal was to be able to read through a bunch of  sub directories, access a specific file in each directory and read the file for specific lines of data then do some cleanup to the data and then write the data in a format that is good for importing or import directly into the application.

When the command button is pressed it presents the user with some questions that upon the users response it creates a file that contains all the subdirectories that will be used as the list to create a path variable to read a specific file.

At this point I take the directory name and do a dir with the b switch directed to a file (thanks for the idea Bob Hansen)

If this file is created successfully the next process reads the file using 1 line at a time to build the path for my subroutine that parses the specific file in that directory for the data.
It then writes out the directory and filename to a log before going on to the next subdirectory and file to process.

This code works fine as long as it is pointed to a real hard drive it does not work reading a cd.  If I copy the directories from the cd to the hard drive and then point the program at that drive it works great.

Before I spend any more time trying to troubleshoot my code I figured I would check with the more experienced external file I-O command users to see if there are issues working from a cd, other then problem code.

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: external file input output functions and comma
Reply #1 - May 7th, 2004 at 7:40pm
Print Post Print Post  
Bob,

Under the hood, files can be opened in "read mode", "write mode" or "read/write mode". The SBasic file commands open files in "read/write mode" so that you can go from reading to writing without having to reopen the file in a different mode. We may well offer an additional "openFile" command that allows you to set the mode.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: external file input output functions and comma
Reply #2 - May 7th, 2004 at 7:51pm
Print Post Print Post  
Hello Robert

Glad to hear that the "dir /b >dirlist.txt" worked for you.  Since we spoke, I ran across this utility that may make your life a little easier:

JDirPrint is a freeware utility available from:
http://www.spadixbd.com/freetools/JDirPrint.htm

You could possible use jdirprint with @shell vs. using dir /b?

The JR Directory Printer Utility allows you to print a listing of every file contained within a directory and/or subdirectory(ies).

The result displayed in NotePad or default text editor as "dirprint.txt" file. This file is created in "JR Directory Printer" installtion folder, each time you click "Start" button.

Options:

Check Recurse Sub-directories option to see a complete list of all subdirectories and all files in all directories.

The Lowercase Filename option will force all file names into lowercase regardless of the actual file name.

Dos style filename option will limit the file name length within 8 chars.

Display Sub-directories will result in a list of all subdirectories contained under the selected directory along with a list of all individual files contained under the root directory.  It will not list all subdirectories or individual files contained in the main subdirectories.  To see a complete list of all subdirectories and all files in all directories, you would check the Recurse Sub-directories option and click on the Start button. This would rewrite the"dirprint.txt" file using the new options.

You can limit length file names so that they fits properly in list. By default this value is 35 chars.

You can check/uncheck Display Size, DateTime and Attributes option to list/unlist the file size, modified date/time and file attributes (a - Archives, r - Read Only, s - System, h - Hidden).

Download (size: 173 KB)
=======================
Re your reading CD issue.  Here's a thought, but I can't guarantee it is a solution.  Let me know results if you try this.

I believe that your working directory may have to be writeable for a system temp scratch file when you do a DIR listing.  At times, many CDs are Read Only after files are burned onto it.  So when you are trying to read the directories, perhaps be sure that your current working directory is somplace on your hard drive first.

If D is your CD, and C is your hard drive, do something like:
C:\
CD\temp
DIR  D:\Folder\*.* /b >dirlist.txt

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: external file input output functions and comma
Reply #3 - May 7th, 2004 at 8:56pm
Print Post Print Post  
Thanks for the information everyone  Cheesy

As usual this forum has saved me from pulling the little remaining hair I have left from my head.

I tried your suggestion Bob Hansen but it does not solve the problem. The  best workaround I found is adding  a subroutine that calls a bat file from @shell that creates a temporary directory, copies the entire cd to the directory then changes attributes on the files and gives control back to Sbasic. After Sbasic completes its last process I display an @msg window with some results and ask the user if they are ready to end or work on another cd. When I receive a positive response I remove all the files from the temporary directory and either end the program or start the process again on the next cd.

It slows down the process a little but it works fine and pressing a command button and walking away is a lot better then sitting and manually copying and manipulating data in a gazillion files.


  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: external file input output functions and comma
Reply #4 - May 7th, 2004 at 9:08pm
Print Post Print Post  
Quote:
I tried your suggestion
  I am guessing that was the one about the current directory.

Let me know if you try the utility JDirPrint.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged