Page 1 of 1

Unknown Error #32

PostPosted: Tue Mar 16, 2010 10:05 am
by reinier maliepaard
A simple solution for the Unkown Error #32
In my MCMusiceditor (www.mcmusiceditor.com) a multi-user database is filled with data by application 1 (NeobookDB-plugin) that is read by application 2 after 2 seconds. Application 2 reads the database-data and writes the data -if modified- to a text-file, which is processed by third-party software = application 3 (which makes a postscriptfile).

The MCMusiceditor sometimes produced at random the Unknown Error #32. I had to find a solution because of the third-party software, which only reads textfiles.

I experimented, found a way to reproduce the Unknown Error #32 and finally a simple solution.

Problem
Microsoft information on #32 Error: "the process cannot access the file because it is being used by another process." This makes sense beacause application 2 and application 3 could act on the text-file simultaneously.

Reproducing the error
I made for demonstration-purposes a sample pub error_catcher.pub (application 1), which writes continuously the text ("this is a test") to the textfile test.txt

While "[doorgaan]" "=" "1"
FileWrite "[file]" "Append" "this is a test"
EndWhile

I made also an sample pub error_catcher2.pub (application 2), which is opens test.txt and processes all the lines of the file within a loop for reading.

Loop "1" "[flen]" "[x]"
FileRead "[file]" "[x]" "[r]"
EndLoop

This results in the Unknown Error #32

Solution FileCopy
The solution: application 2 starts with copying test.txt to test2.txt, opens then test2.txt and processes all the lines of the file within a loop for reading. The error #32 is now not produced! So FileCopy is NOT seen by Windows as processing a file...

Below two sample pubs app1 and app2. I hope it is useful for you.

Regards,
Reinier Maliepaard

------------------------------------------------------------------------------------
CODE errorcatcher.pub (app1)

NBW Publication Source File
(C)1993-2009 NeoSoft Corp.
Title=App1
Language=US
NeoBookVer=5,60
ScreenColors=16777216
ScreenWidth=320
ScreenHeight=300
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
ShutdownAction=SetVar "[doorgaan]" "0"¶SetVar "[file]" "[PubDir]test.txt"¶SetVar "[file_copy]" "[PubDir]test2.txt"¶FileExists "[file]" "[izz]"¶If "[izz]" "=" "True"¶ FileErase "[file]"¶EndIf¶FileExists "[file_copy]" "[izz]"¶If "[izz]" "=" "True"¶ FileErase "[file_copy]"¶EndIf
ShapeTransColor=536870912
Icon=D:\software_artez_2010\icons\sharp_grey\ico\options.ico
CompressPub=Yes
CompiledName=C:\Documents and Settings\Maliepaard\Bureaublad\testmusiceditor\error_catcher.exe
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
FontsToCompile=|
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
ReqExLevel=1
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
EffectSpeed=0
PgEnterAction=SetVar "[doorgaan]" "1"
ObjectType=3
Name=PushButton2
X=44
Y=42
W=219
H=42
Anchor=0
Text=Step 1. Make test.txt file¶appending continuously some text
Align=2
ImageStyle=0
ObjAction=SetVar "[doorgaan]" "1"¶SetVar "[file]" "[PubDir]test.txt"¶SetVar "[file_copy]" "[PubDir]test2.txt"¶FileExists "[file]" "[izz]"¶If "[izz]" "=" "True"¶ FileErase "[file]"¶EndIf¶FileExists "[file_copy]" "[izz]"¶If "[izz]" "=" "True"¶ FileErase "[file_copy]"¶EndIf¶¶Delay "200"¶¶While "[doorgaan]" "=" "1"¶ FileWrite "[file]" "Append" "this is a test"¶EndWhile
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=3
Name=PushButton3
X=43
Y=217
W=221
H=42
Anchor=0
Text=Step 3. Stop making test.txt file
Align=2
ImageStyle=0
ObjAction=SetVar "[doorgaan]" "0"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=1
ObjectType=8
Name=Text5
X=45
Y=135
W=223
H=34
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 Step 2: go to app.2 }}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=3

--------------------------------------------------------------------------------
CODE errorcatcher2.pub (app2)

NBW Publication Source File
(C)1993-2009 NeoSoft Corp.
Title=app2
Language=US
NeoBookVer=5,60
ScreenColors=16777216
ScreenWidth=320
ScreenHeight=300
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=2
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
ShapeTransColor=536870912
Icon=D:\software_artez_2010\icons\sharp_grey\ico\options.ico
CompressPub=Yes
CompiledName=C:\Documents and Settings\Maliepaard\Bureaublad\testmusiceditor\error_catcher2.exe
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
FontsToCompile=|
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
ReqExLevel=1
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
EffectSpeed=0
PgEnterAction=SetVar "[doorgaan]" "1"
ObjectType=3
Name=PushButton5
X=4
Y=119
W=191
H=42
Anchor=0
Text=Step 2. Try to process the file
Align=2
Key=13
ImageStyle=0
ObjAction=SetVar "[file]" "[PubDir]test.txt"¶SetVar "[file_copy]" "[PubDir]test2.txt"¶¶.Delay "200"¶¶FileCopy "[file]" "[file_copy]"¶Delay "200"¶FileExists "[file_copy]" "[izz]"¶If "[izz]" "=" "True"¶ FileLen "[file_copy]" "[flen]"¶ Loop "1" "[flen]" "[x]"¶ FileRead "[file_copy]" "[x]" "[r]"¶ EndLoop¶EndIf
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=1
ObjectType=8
Name=Text3
X=204
Y=121
W=89
H=41
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 [x]}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=2
ObjectType=8
Name=Text6
X=8
Y=200
W=292
H=33
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 Click the Enter-key again and again}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=3