cant read from cdrom

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

cant read from cdrom

Post by BlackWisdom » Tue Jan 23, 2007 5:49 am

Guys Im really stumped with this one - this is going to sound pretty amatuerish to say the least - look at this code:


ReadFile>D:\CDCount\CD1\results.txt,file



Thats it - only one line, I have cleared all blank spaces and when I run it I get an unknown error dialog box. This file in on a cd rom (which is D drive). If I put this file on the hard drive (C drive) theres no problem. Im running MSched 7.4 on w2k am I missing something...

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jan 23, 2007 6:28 am

What do you mean with
I have cleared all blank spaces
Does the actual file have spaces, but you have removed them in the ReadFile command? If yes, that was wrong, you need exact spelling, including in the path and file names.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

Post by BlackWisdom » Tue Jan 23, 2007 6:39 am

Hi Bob thanks for the quick reply - what I meant was I used the "Remove Trailing Spaces" in the edit option. The file name is exact.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jan 24, 2007 12:55 am

Ah, sorry for asking the wrong question.

So, you are running a one line macro as detailed above, and when you run it, you get an error message box ......

Please provide exact content of message box.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Wed Jan 24, 2007 5:42 am

Are you able to open the file manually? No errors? Just wondering if it is an issue with the CD...

BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

Post by BlackWisdom » Mon Jan 29, 2007 6:44 pm

Hi Bob / Skunkworks

I can access the txt file directly from the CD with no problem







Here is what the message says:

Unknown has generated errors and will be closed by windows
You will need to restart the program


An error log is being created

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Jan 29, 2007 6:55 pm

Please provide the entire script.
Point out where the problem occurs.
Provide a log of the macro running.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 29, 2007 6:59 pm

Also... what does the error log say?
Start > Run > eventvwr.msc

Searching the microsoft knowledgebase for the phrase: "has generated errors and will be closed by windows" found nothing specific to your exact error or problem. But there does seem to be a pattern. This particular error seems to be prevalent in Win 2000 prior to SP4. There are also articles which mention this type of error when explorer.exe (in Win 2000) tries to access a read-only file. Aren't most CD files marked Read-Only?

Perhaps you could upgrade to Win 2000 SP4.

Or, a workaround might be to add the line:

CopyFile>D:\CDCount\CD1\results.txt,%TEMP_DIR%results.txt


Then, assuming the copyfile> doesn't throw a similar error, change the readfile line to:

ReadFile>%TEMP_DIR%results.txt,file

BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

Post by BlackWisdom » Mon Jan 29, 2007 9:48 pm

Hi JRL:

I ran the exe file to get an updated log - I then checked the application / Security and system logs - there was no updated log created.

I am running W2k SP4 - also if I change the command from ReadFile to ReadLn then all the lines on the text file on the CD are read its only if I attempt to use ReadFile command that the error occurs. I used a message box to confirm this

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jan 30, 2007 1:59 pm

So you have found a way to make this work by using ReadLn>. Or is there some reason ReadLn> can't be used?

In any case, the error is a Windows system error not a Macro Scheduler error, so you need to make your script work around it. I would guess from what I read on the Microsoft web site that Windows 2000 doesn't like ReadFile> on a read only file. So the ReadFile> function is the "Unknown" portion of the error message.

BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

Using ReadLn

Post by BlackWisdom » Mon Feb 12, 2007 3:20 pm

Sorry about the long break in responses guys:

JRl youre right I can use ReadFile but here is what I was trying to do:

Lets say you grab a file using ReadFile - and the variable is labed file ie:

ReadFile>D:\temp\test.txt,file (keep in mind D: is the CDROM drive)

Can the variable "file" then be used to read lines from the file that is now stored in memory" ie:



ReadLn>%file%,k,line

doing this would make accessing and reading the file much faster because the file is preloaded in memory - that is wby I was attempting to read the file on the CDROM. Am I making sense...??

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Feb 12, 2007 7:14 pm

JRl youre right I can use ReadFile but here is what I was trying to do: Lets say you grab a file using ReadFile...
I assume you mean that you could use ReadLn but you'd rather use ReadFile.

I thought the issue here was that you are getting a Microsoft error when you try to use ReadFile from the CD-ROM? If that is the case then I think you have two paths you could follow.

1) Use ReadLn instead of ReadFile. It might be a little slower if the file is large, on the other hand if the file is quite large, ReadFile will possibly throw an "Out of Memory" error.

2) Copy the file from your CD drive (D:) to you hard drive (C:) and then use Readfile to read the C drive copy.


Can the variable "file" then be used to read lines from the file that is now stored in memory" ie:
ReadLn>%file%,k,line
Not exactly. Once you have the file assigned to a variable by using ReadFile, (in the case of your example the variable is "file") you can divvy up the individual lines and assign each one of them to a variable by using the Separate> function. The individual lines of a Windows text file are divided up by the characters ASCII 13 (Carriage Return) and ASCII 10 (Line Feed). In Macro Scheduler this unique combination has a predefined variable that can be called in your script by entering %CRLF%.
Therefore, the line:

Separate>%file%,%CRLF%,var


Will assign each line of the file to the variables var_X where "X" is the line number. In other words line one will be assigned to variable var_1, line two will be assigned to variable var_2, and so on...

After assigning the lines to variables the lines can be accessed by calling them from a loop. Something like:

Let>k=0
Repeat>k
Add>k,1
Let>line=var_%k%
//The variable "line" now contains the contents of line "k" similar to the ReadLn example you posted.
//Do something with "line"
Until>k=var_count


Hope this helps,
Dick

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts