I have serious problem with Replace-command and WinNT4.
In the code below i have emphesized the failing command.
What happens is that very randomly this Replace is only
partially performed.
The resulting buffer (15000 bytes give and take 1024 bytes)
is translated into EBCDIC rest remain in ASCII
Sometimes 5000 bytes sometimes 14000 bytes are translated.
It seems to me that NT4 is switching away from this code before
the memory is completely updated (Replace is performed),
and when it comes back again it seems not to carry on with Replace.
This code is working on Win95 but it is in the main EXE-file
Running without problem for a year.
This code seems to be working on WIN2000
(havent been able to prove otherwise) The code is in a DLL
This code does not work in NT4 SP6a (code in DLL)
My customer runs this code on both WIN95 and WINNT4
The problem seems to occure when VNC a TCP/IP based remote-access
program is run on the machine. But it also sometimes happens if I
start Explorer or some other program.(with VNC unloaded)
I need a very quick sulotion to this problem.
Can someone help?
Can I prevent context-switching around the relace-command?
-------------
Fred
mailto:[email protected][email protected]</A>
http://www.oxenby.se
In the code below i have emphesized the failing command.
What happens is that very randomly this Replace is only
partially performed.
The resulting buffer (15000 bytes give and take 1024 bytes)
is translated into EBCDIC rest remain in ASCII
Sometimes 5000 bytes sometimes 14000 bytes are translated.
It seems to me that NT4 is switching away from this code before
the memory is completely updated (Replace is performed),
and when it comes back again it seems not to carry on with Replace.
This code is working on Win95 but it is in the main EXE-file
Running without problem for a year.
This code seems to be working on WIN2000
(havent been able to prove otherwise) The code is in a DLL
This code does not work in NT4 SP6a (code in DLL)
My customer runs this code on both WIN95 and WINNT4
The problem seems to occure when VNC a TCP/IP based remote-access
program is run on the machine. But it also sometimes happens if I
start Explorer or some other program.(with VNC unloaded)
I need a very quick sulotion to this problem.
Can someone help?
Can I prevent context-switching around the relace-command?
Code:
'===[LOKAL VARASA2XFP-RUTIN]===================== Function ASAVar_TO_XFP()As Integer Local Cmd$,Rad$,CmdPos% Local rc%,Tmp$,Rl%,z1%,z2%,z3% On Error Resume Next Tmp$ ="":glbInBuff="" gIn.Refill = 1 '..loopa genom filen............................. ErrClear:Seek gIn.FilNr, gIn.FilPos If ErrClear > 0 Then Function = 120: Exit Function Do apiSleep 0 If gIn.BytesToRead > 0 And gIn.Refill <> 0 Then gIn.Refill = 0 gIn.BuffSize = Min(gIn.BytesToRead,gIn.MaxBuff) ErrClear Get$ gIn.FilNr, gIn.BuffSize, glbInBuff If ErrClear > 0 Then rc%=102:GoSub DebugExit:Function = 102: Exit Function gIn.FilPos = Seek(gIn.FilNr) If ErrClear > 0 Then rc%=120:GoSub DebugExit:Function = 120: Exit Function gIn.BytesToRead = gIn.FilLen - (gIn.FilPos - 1) '..Avlägsna Trailing "1A" och NULL........... If gIn.BytesToRead < 1 Then glbInBuff = Rtrim$(glbInBuff,Any Chr$(0,&H1A)) If Right$(glbInBuff,1)<>Chr$(10) Then glbInBuff = glbInBuff + Chr$(10) End If '--Översätt Ascii Till Ebcdic-------------------- Select Case gIn.Charset Case %ASC2EBC z1%=&HCA:z2%=&HB3:z3%=&HFA 'This is where the Error happens [b]Replace Any glbAscii With glbEbcdic In glbInBuff[/b] Case %ANS2EBC z1%=&HDE:z2%=&HA1:z3%=&H8C Replace Any glbAnsi With glbEbcdic In glbInBuff Case Else z1%=&HCA:z2%=&HFA:z3%=&HFC End Select '--Merge buffer---------------------------------- glbInBuff = Tmp$ + glbInBuff '--Tabort CR och FF------------------------------ glbInBuff = Remove$(glbInBuff$,Any Chr$(12,13)) '--rätta till buffer----------------------------- gIn.BuffSize = Len(glbInBuff) gIn.BuffPos = 1 '--rapportera filpos----------------------------- If ProgressReport(gIn.FilPos,gIn.FilLen)<> 0 Then rc%=200:GoSub DebugExit:Function = 200: Exit Function End If '--Konvertera raden------------------------------ gIn.RadSlut = Instr(gIn.BuffPos,glbInBuff, Chr$(10)) If gIn.RadSlut = 0 Then rc%=110:GoSub DebugExit:Function = 110: Exit Function Rad$ = Mid$(glbInBuff,gIn.BuffPos,gIn.RadSlut - gIn.BuffPos) gIn.BuffPos = gIn.RadSlut + 1 '--Dags att fylla på buffer---------------------- If gIn.BuffSize - gIn.BuffPos < 1024 Then Tmp$ = Mid$(glbInBuff,gIn.BuffPos) gIn.Refill = 1 End If '--Validera Cmd/rad------------------------------ Rad$=Rtrim$(Rad$,Any Chr$(0,64)) Select Case Len(Rad$) Case > 1 : Cmd$ = Left$(Rad$,1):Rad$ = Mid$(Rad$,2) Case = 1 : Cmd$ = Rad$:Rad$ = Chr$(&H40) Case Else: Cmd$ = Chr$(&H40):Rad$ = Chr$(&H40) End Select '--Hantera NonAsa-kommandon---------------------- Select Case Asc(Cmd$) Case &H5C :cmd$ = Chr$(&H40) Case &H4F,z1%,z2%,z3%:cmd$ = Chr$(&HC1): rad$ = Chr$(&H0E) + rad$ End Select '--Returnera Normaliserat kommando--------------- CmdPos% = Instr(Chr$(078,064,240,096,241,242,243,244, _ 245,246,247,248,249,193,194,195),Cmd$) 'This is where the program finds out about it [b] If CmdPos% = 0 Then Replace Any glbEbcdic With glbAscii In Rad$ gErr.FelRad = "ERROR 110 CMD = " + Hex$(Asc(Cmd$)) + " RAD = " + Rad$ rc%=110:GoSub DebugExit:Function = 110: Exit Function End If [/b] '--Skicka dem till PCC-buffer-------------------- Cmd$ = Mid$(Chr$(001,009,017,025,137,145,153,161, _ 169,177,185,193,201,209,217,225), CmdPos%, 1) '--Skapa PCC-rad--------------------------------- Rl% = 1 + Len(Rad$) If Rl% > 255 Then rc%=111:GoSub DebugExit:Function = 111:Exit Function glbUtBuff = glbUtBuff + Mki$(Rl%) + Cmd$ + Rad$ + Mki$(Rl%) '--skriv ut buff--------------------------------- If Len(glbUtBuff) > gUt.MaxBuff Then ErrClear:Put$ gUt.FilNr,glbUtBuff If ErrClear > 0 Then Function = 103:Exit Function glbUtBuff = "" End If '--är filen processad---------------------------- If gIn.BytesToRead < 1 And gIn.BuffPos >= gIn.BuffSize Then Exit Do Loop '--Töm Utbuffer till disk------------------------ If Len(glbUtBuff) > 0 Then ErrClear:Put$ gUt.FilNr,glbUtBuff If ErrClear > 0 Then Function = 103:Exit Function glbUtBuff = "" End If Function = 0 Exit Function DebugExit: Local q%,DebugString$,CSet$ CSet$ = " NONE " & " RC= " & Format$(Rc%) If gIn.CharSet= %ASC2EBC Then CSet$ =" ASC2EBC " & " RC= " & Format$(Rc%) If gIn.CharSet= %ANS2EBC Then CSet$ =" ANS2EBC " & " RC= " & Format$(Rc%) ErrClear:q% = FreeFile ErrClear:Open gDebugFil For Binary As #q% ErrClear:Put$ q%,glbInBuff DebugString$ = "|CharSet= " & CSet$ & "|FilPos= " & Format$(gIn.FilPos) & " |BuffPos= " & Format$(gIn.BuffPos) Put$ q%,DebugString$ Close q% Return End Function
-------------
Fred
mailto:[email protected][email protected]</A>
http://www.oxenby.se
Comment