Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default "Headroom" on <Files=99 in config.sys

Hi

As I understand, the command
files=99
in config.sys or config.nt allows 99 files to be open.

How do I know how many have been "used up" and therefore
how many remain to be used, or have I missed the point?

If you need more info then please post back.

Thanks

Tim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default "Headroom" on <Files=99 in config.sys

I thing that setting is obsolete under Windows, Tim. In the old DOS days
machine memory was limited to 640k and you had to worry about allocating it
for various purposes. Each "file" allocated took a little bit. I think you
can safely forget about it. If Config.sys has an entry it's for "legacy"
purposes I would guess. My Config.sys is empty btw.

--
Jim Rech
Excel MVP


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default "Headroom" on <Files=99 in config.sys

Jim

that's really interesting: we still have this in our set-up at work - I know
because I have a VBA application which broke the limit....

am on Windows XP here at home and, as you say, there is no config file (that
I can find)

but at work the limitation exists and is not easily put right - if I
distribute the application I need to ensure the number of open files is kept
below 99

thanks for responding

Tim


"Jim Rech" wrote in message
...
I thing that setting is obsolete under Windows, Tim. In the old DOS days
machine memory was limited to 640k and you had to worry about allocating

it
for various purposes. Each "file" allocated took a little bit. I think

you
can safely forget about it. If Config.sys has an entry it's for "legacy"
purposes I would guess. My Config.sys is empty btw.

--
Jim Rech
Excel MVP




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default "Headroom" on <Files=99 in config.sys

Pure speculation follows:

If it's in the config.sys file, then it's a pc wide setting--all
applications(???).

If it's all applications, how can you check to see what's open or even how many
are open?

And with lots of windows applications, files are opened that I never know about
(or even care about). All those DLLs and other external files.

And pulling my old DOS 3.2 manual:

Purpose: This command sets the number of open file handles compatible with
XENIX(R) that the MS-DOS system calls can access.

Syntax: files=<x

Comments: <x represents the number of open files handles that the system calls
can access. System calls 2FH throuh 60H are compatible with the XENIX operating
system.

<x can be any number between 8 and 255. The fault value is 8. Any value
higher than 20 serves no function.

And pulling from my old DOS 5.0 manual (I'm a pack rat!):
Files: Sets the number of files that MS-DOS allows to be open at one time.
In the 5.0 manual, it does say you can have up to 255 files open at one time.

In the 6.0 userguide, it says to refer to the online help. (I _don't_ have that
anymore!)

But I can't imagine that this is important anymore.

Tim Childs wrote:

Jim

that's really interesting: we still have this in our set-up at work - I know
because I have a VBA application which broke the limit....

am on Windows XP here at home and, as you say, there is no config file (that
I can find)

but at work the limitation exists and is not easily put right - if I
distribute the application I need to ensure the number of open files is kept
below 99

thanks for responding

Tim

"Jim Rech" wrote in message
...
I thing that setting is obsolete under Windows, Tim. In the old DOS days
machine memory was limited to 640k and you had to worry about allocating

it
for various purposes. Each "file" allocated took a little bit. I think

you
can safely forget about it. If Config.sys has an entry it's for "legacy"
purposes I would guess. My Config.sys is empty btw.

--
Jim Rech
Excel MVP



--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default "Headroom" on <Files=99 in config.sys

Tim & Dave,
It is still a problem. http://ittimes.ucdavis.edu/may2000/348sb.html And
read the link at the bottom of the page.

And although not a VBA solution http://www.sysinternals.com/ Look for the
"Filemon" download.

--

John

johnf202 at hotmail dot com


"Dave Peterson" wrote in message
...
Pure speculation follows:

If it's in the config.sys file, then it's a pc wide setting--all
applications(???).

If it's all applications, how can you check to see what's open or even how

many
are open?

And with lots of windows applications, files are opened that I never know

about
(or even care about). All those DLLs and other external files.

And pulling my old DOS 3.2 manual:

Purpose: This command sets the number of open file handles compatible

with
XENIX(R) that the MS-DOS system calls can access.

Syntax: files=<x

Comments: <x represents the number of open files handles that the system

calls
can access. System calls 2FH throuh 60H are compatible with the XENIX

operating
system.

<x can be any number between 8 and 255. The fault value is 8. Any value
higher than 20 serves no function.

And pulling from my old DOS 5.0 manual (I'm a pack rat!):
Files: Sets the number of files that MS-DOS allows to be open at one

time.
In the 5.0 manual, it does say you can have up to 255 files open at one

time.

In the 6.0 userguide, it says to refer to the online help. (I _don't_

have that
anymore!)

But I can't imagine that this is important anymore.

Tim Childs wrote:

Jim

that's really interesting: we still have this in our set-up at work - I

know
because I have a VBA application which broke the limit....

am on Windows XP here at home and, as you say, there is no config file

(that
I can find)

but at work the limitation exists and is not easily put right - if I
distribute the application I need to ensure the number of open files is

kept
below 99

thanks for responding

Tim

"Jim Rech" wrote in message
...
I thing that setting is obsolete under Windows, Tim. In the old DOS

days
machine memory was limited to 640k and you had to worry about

allocating
it
for various purposes. Each "file" allocated took a little bit. I

think
you
can safely forget about it. If Config.sys has an entry it's for

"legacy"
purposes I would guess. My Config.sys is empty btw.

--
Jim Rech
Excel MVP



--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default "Headroom" on <Files=99 in config.sys

Doesn't that first link describe a problem with Mac's? The windows info looked
like it was just referring to a utility that helps find what's open--not that it
still causes problems.

It points back to this:
http://ittimes.ucdavis.edu/may2000/348.html

And that has this line at the end:

(By the way, in Macintosh OS 9, Apple boosted the number of simultaneously open
files to 8,169.)

====
I don't think I've had this problem with newer versions (win95) of windows.



jaf wrote:

Tim & Dave,
It is still a problem. http://ittimes.ucdavis.edu/may2000/348sb.html And
read the link at the bottom of the page.

And although not a VBA solution http://www.sysinternals.com/ Look for the
"Filemon" download.

--

John

johnf202 at hotmail dot com

"Dave Peterson" wrote in message
...
Pure speculation follows:

If it's in the config.sys file, then it's a pc wide setting--all
applications(???).

If it's all applications, how can you check to see what's open or even how

many
are open?

And with lots of windows applications, files are opened that I never know

about
(or even care about). All those DLLs and other external files.

And pulling my old DOS 3.2 manual:

Purpose: This command sets the number of open file handles compatible

with
XENIX(R) that the MS-DOS system calls can access.

Syntax: files=<x

Comments: <x represents the number of open files handles that the system

calls
can access. System calls 2FH throuh 60H are compatible with the XENIX

operating
system.

<x can be any number between 8 and 255. The fault value is 8. Any value
higher than 20 serves no function.

And pulling from my old DOS 5.0 manual (I'm a pack rat!):
Files: Sets the number of files that MS-DOS allows to be open at one

time.
In the 5.0 manual, it does say you can have up to 255 files open at one

time.

In the 6.0 userguide, it says to refer to the online help. (I _don't_

have that
anymore!)

But I can't imagine that this is important anymore.

Tim Childs wrote:

Jim

that's really interesting: we still have this in our set-up at work - I

know
because I have a VBA application which broke the limit....

am on Windows XP here at home and, as you say, there is no config file

(that
I can find)

but at work the limitation exists and is not easily put right - if I
distribute the application I need to ensure the number of open files is

kept
below 99

thanks for responding

Tim

"Jim Rech" wrote in message
...
I thing that setting is obsolete under Windows, Tim. In the old DOS

days
machine memory was limited to 640k and you had to worry about

allocating
it
for various purposes. Each "file" allocated took a little bit. I

think
you
can safely forget about it. If Config.sys has an entry it's for

"legacy"
purposes I would guess. My Config.sys is empty btw.

--
Jim Rech
Excel MVP



--

Dave Peterson


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default "Headroom" on <Files=99 in config.sys

Hi Dave,
It addresses open file resources for all the major o/s's.
I spent awhile on google and saw several mentions of the old "out of memory"
problem being traced to "to many open files"

There are several API windows error message constants dealing with "to many
open files", but I didn't see anything about querying for available files.
There must be some or windows wouldn't need an error message.


--

John

johnf202 at hotmail dot com


"Dave Peterson" wrote in message
...
Doesn't that first link describe a problem with Mac's? The windows info

looked
like it was just referring to a utility that helps find what's open--not

that it
still causes problems.

It points back to this:
http://ittimes.ucdavis.edu/may2000/348.html

And that has this line at the end:

(By the way, in Macintosh OS 9, Apple boosted the number of simultaneously

open
files to 8,169.)

====
I don't think I've had this problem with newer versions (win95) of

windows.



jaf wrote:

Tim & Dave,
It is still a problem. http://ittimes.ucdavis.edu/may2000/348sb.html And
read the link at the bottom of the page.

And although not a VBA solution http://www.sysinternals.com/ Look for

the
"Filemon" download.

--

John

johnf202 at hotmail dot com

"Dave Peterson" wrote in message
...
Pure speculation follows:

If it's in the config.sys file, then it's a pc wide setting--all
applications(???).

If it's all applications, how can you check to see what's open or even

how
many
are open?

And with lots of windows applications, files are opened that I never

know
about
(or even care about). All those DLLs and other external files.

And pulling my old DOS 3.2 manual:

Purpose: This command sets the number of open file handles

compatible
with
XENIX(R) that the MS-DOS system calls can access.

Syntax: files=<x

Comments: <x represents the number of open files handles that the

system
calls
can access. System calls 2FH throuh 60H are compatible with the XENIX

operating
system.

<x can be any number between 8 and 255. The fault value is 8. Any

value
higher than 20 serves no function.

And pulling from my old DOS 5.0 manual (I'm a pack rat!):
Files: Sets the number of files that MS-DOS allows to be open at one

time.
In the 5.0 manual, it does say you can have up to 255 files open at

one
time.

In the 6.0 userguide, it says to refer to the online help. (I _don't_

have that
anymore!)

But I can't imagine that this is important anymore.

Tim Childs wrote:

Jim

that's really interesting: we still have this in our set-up at

work - I
know
because I have a VBA application which broke the limit....

am on Windows XP here at home and, as you say, there is no config

file
(that
I can find)

but at work the limitation exists and is not easily put right - if I
distribute the application I need to ensure the number of open files

is
kept
below 99

thanks for responding

Tim

"Jim Rech" wrote in message
...
I thing that setting is obsolete under Windows, Tim. In the old

DOS
days
machine memory was limited to 640k and you had to worry about

allocating
it
for various purposes. Each "file" allocated took a little bit. I

think
you
can safely forget about it. If Config.sys has an entry it's for

"legacy"
purposes I would guess. My Config.sys is empty btw.

--
Jim Rech
Excel MVP



--

Dave Peterson


--

Dave Peterson



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default "Headroom" on <Files=99 in config.sys

Hi

in this bit of code is where I originally encountered the problem (see
"BOOKMARK" for workaround) and so limited my self to opening just 10 files
at a time, other wise where the range was large (sometimes 1000, i recall)
the error too many files did appear

I hope I have put in all the called functions - the problem is that it has
never been finished off/tidied up

(Dave, you may seem some of your coding in there somewhere!)

Regards

Tim


Option Explicit
Option Compare Text
Option Base 1

Declare Function GetComputerName& Lib "kernel32" _
Alias "GetComputerNameA" (ByVal lbbuffer As String, nsize As Long)

Public vLineInfo As Variant

Sub IterativeRunNBTstat()

Dim RetVal
Dim Temp
Dim lCount As Long 's/b long?
'Temp = Chr(34) & "<03" & Chr(34) 'for extracting a particular line
Temp = ""

Dim StartMachineNo As Long
Dim EndMachineNo As Long
Dim lTotalNo As Long
Dim sMachineID As String
Dim lLastRow As Long

StartMachineNo = WorksheetFunction.VLookup("StartNumber",
ThisWorkbook.Sheets("Main").Range("A:B"), 2, False)
EndMachineNo = WorksheetFunction.VLookup("EndNumber",
ThisWorkbook.Sheets("Main").Range("A:B"), 2, False)

If EndMachineNo < 1 Then EndMachineNo = StartMachineNo

lTotalNo = EndMachineNo - StartMachineNo + 1

Dim StartTime
StartTime = Now
lLastRow = GetLastRow(2, 2)
Dim iMaxRange
iMaxRange = 10

For lCount = StartMachineNo To EndMachineNo

sMachineID = "ox" & Right("00" & lCount, 6)

'BOOKMARK
If lTotalNo <= iMaxRange Then
ShellAndWait ("command.com /c nbtstat -a " & sMachineID & " " &
Environ$("temp") & "\" & sMachineID & ".txt")
Else '10 more machines, no need for delay while NBTSTAT returns an
answer
RetVal = Shell("command.com /c nbtstat -a " & sMachineID & " " &
Environ$("temp") & "\" & sMachineID & ".txt", 0) ' was 6
'Application.Wait Now() + TimeValue("00:00:04")
End If
Next lCount

If lTotalNo iMaxRange Then
Do Until Now - StartTime TimeValue("00:00:10")
Debug.Print "waiting"
Application.Wait Now + TimeValue("00:00:02")
Loop
End If

For lCount = StartMachineNo To EndMachineNo
sMachineID = "ox" & Right("00" & lCount, 6)

ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 2) = lCount
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 3) = sGetNameCharsSAT(Environ$("temp") & "\" & sMachineID & ".txt")
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 5) = vLineInfo
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 4) = Now()
Next lCount
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo + 1,
2).Select
Debug.Print Format((Now - StartTime), "hh:mm:ss") & " seconds"
'MsgBox sGetNameCharsSAT("C:\Temp\Test2.txt")
End Sub


Function ReturnName1() As String
Dim z As String * 64
GetComputerName z, 64
ReturnName1 = Left(z, InStr(1, z, Chr(0)) - 1)
End Function

Public Function GetLastRow(FirstCol As Integer, LastCol As Integer) As Long

Dim ColLastRow As Long
Dim i As Integer

For i = FirstCol To LastCol
ColLastRow = Columns(i).Find("*", , , , , xlPrevious).Row 'Finds data
cells, not formatted ones..
If ColLastRow GetLastRow Then GetLastRow = ColLastRow
Next i

End Function

Function sGetNameCharsSAT(sFullFileName As String)
Dim sOutput
Dim iCounter
Dim iPos
Dim iLineNo As Integer
Dim iFileNum As Integer
Dim strTemp As String
Dim Msg As String
Dim sTemp(20) As String
'Environ$("temp") & "\test2.txt "
'get next available file number
iFileNum = FreeFile
'open the file
'Open "C:\windows\desktop\test.txt" For Input As #iFileNum

If FileExists(sFullFileName) = False Then MsgBox "File " & sFullFileName & "
NOT FOUND!!"


Open sFullFileName For Input As #iFileNum
'read the entire first line
On Error Resume Next
Line Input #iFileNum, sTemp(1)

If Err.Number = 62 Then
Close #iFileNum
sOutput = "bombed out"
Else
On Error GoTo 0
If Left(sTemp(1), 4) = "Host" Then
'MsgBox "No data found..."
sGetNameCharsSAT = "Machine not logged onto network"
vLineInfo = ""
Close #iFileNum
Exit Function
End If
On Error Resume Next
For iLineNo = 2 To 18
Line Input #iFileNum, sTemp(iLineNo) 'getting the second line of
input
Next iLineNo
If Err.Number 0 And Err.Number < 62 Then MsgBox "Not normal error -
investigate!!"

On Error GoTo 0
'Range("d6") = sTemp2
For iLineNo = LBound(sTemp, 1) To UBound(sTemp, 1)
Debug.Print iLineNo, sTemp(iLineNo)
Next iLineNo

Close #iFileNum
If Left(sFullFileName, 7) = "C:\Temp" Then Kill sFullFileName
For iCounter = 7 To 18
If InStr(1, sTemp(iCounter), "<03") 0 Then
iPos = InStr(1, sTemp(iCounter), " ")
sOutput = Left(sTemp(iCounter), iPos - 1) '& " Line " & iCounter
vLineInfo = iCounter '" Line with <03 = " &
'instr(1,
End If
Next iCounter

End If



If sTemp(18) = "" Then sOutput = sOutput & ", line 18 null - NO NT user
logged on"
'prob means machine switched on, no user logged on

sGetNameCharsSAT = sOutput

End Function

Public Function FileExists(StFile As String) As Boolean
FileExists = False
On Error Resume Next
If Dir(StFile) < "" Then
If Err.Number = 68 Then 'what is Error 68 - look it up
Err.Clear
On Error GoTo 0
Exit Function
Else
FileExists = True
End If
End If
End Function




"jaf" wrote in message
...
Hi Dave,
It addresses open file resources for all the major o/s's.
I spent awhile on google and saw several mentions of the old "out of

memory"
problem being traced to "to many open files"

There are several API windows error message constants dealing with "to

many
open files", but I didn't see anything about querying for available files.
There must be some or windows wouldn't need an error message.


--

John

johnf202 at hotmail dot com





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default "Headroom" on <Files=99 in config.sys

Makes sense about the error message. But with multitasking OSs with lots of
applications running and background processes, too, how many is too many? And I
wonder if files=### would have any affect.

But the way windows work has always pretty much magic to me.

jaf wrote:

Hi Dave,
It addresses open file resources for all the major o/s's.
I spent awhile on google and saw several mentions of the old "out of memory"
problem being traced to "to many open files"

There are several API windows error message constants dealing with "to many
open files", but I didn't see anything about querying for available files.
There must be some or windows wouldn't need an error message.

--

John

johnf202 at hotmail dot com

"Dave Peterson" wrote in message
...
Doesn't that first link describe a problem with Mac's? The windows info

looked
like it was just referring to a utility that helps find what's open--not

that it
still causes problems.

It points back to this:
http://ittimes.ucdavis.edu/may2000/348.html

And that has this line at the end:

(By the way, in Macintosh OS 9, Apple boosted the number of simultaneously

open
files to 8,169.)

====
I don't think I've had this problem with newer versions (win95) of

windows.



jaf wrote:

Tim & Dave,
It is still a problem. http://ittimes.ucdavis.edu/may2000/348sb.html And
read the link at the bottom of the page.

And although not a VBA solution http://www.sysinternals.com/ Look for

the
"Filemon" download.

--

John

johnf202 at hotmail dot com

"Dave Peterson" wrote in message
...
Pure speculation follows:

If it's in the config.sys file, then it's a pc wide setting--all
applications(???).

If it's all applications, how can you check to see what's open or even

how
many
are open?

And with lots of windows applications, files are opened that I never

know
about
(or even care about). All those DLLs and other external files.

And pulling my old DOS 3.2 manual:

Purpose: This command sets the number of open file handles

compatible
with
XENIX(R) that the MS-DOS system calls can access.

Syntax: files=<x

Comments: <x represents the number of open files handles that the

system
calls
can access. System calls 2FH throuh 60H are compatible with the XENIX
operating
system.

<x can be any number between 8 and 255. The fault value is 8. Any

value
higher than 20 serves no function.

And pulling from my old DOS 5.0 manual (I'm a pack rat!):
Files: Sets the number of files that MS-DOS allows to be open at one
time.
In the 5.0 manual, it does say you can have up to 255 files open at

one
time.

In the 6.0 userguide, it says to refer to the online help. (I _don't_
have that
anymore!)

But I can't imagine that this is important anymore.

Tim Childs wrote:

Jim

that's really interesting: we still have this in our set-up at

work - I
know
because I have a VBA application which broke the limit....

am on Windows XP here at home and, as you say, there is no config

file
(that
I can find)

but at work the limitation exists and is not easily put right - if I
distribute the application I need to ensure the number of open files

is
kept
below 99

thanks for responding

Tim

"Jim Rech" wrote in message
...
I thing that setting is obsolete under Windows, Tim. In the old

DOS
days
machine memory was limited to 640k and you had to worry about
allocating
it
for various purposes. Each "file" allocated took a little bit. I
think
you
can safely forget about it. If Config.sys has an entry it's for
"legacy"
purposes I would guess. My Config.sys is empty btw.

--
Jim Rech
Excel MVP



--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default "Headroom" on <Files=99 in config.sys

This looks like magic, too! But if it works, ...

Tim Childs wrote:

Hi

in this bit of code is where I originally encountered the problem (see
"BOOKMARK" for workaround) and so limited my self to opening just 10 files
at a time, other wise where the range was large (sometimes 1000, i recall)
the error too many files did appear


<<snipped

--

Dave Peterson



  #11   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default "Headroom" on <Files=99 in config.sys

Hi Tim,
Sorry, all I see is questions.<vbg
I see both a shell and shellandwait being used. Both use /c which kills the
command window when done.
Dumping the nbtstat to a text file should only take milliseconds.

The point being, once the process has completed the o/s will close the
file(s).
Doing 1000 files may overload the command processor buffer so doing a pause
in each loop should work.
This may be why you were seeing "to many open files".
If you want to use application.wait I think 1 second is the lowest
resolution.
Using DoEvents won't hurt either.

As a test, do a debug.print timer in each loop to see how long the shell is
taking.


I would suggest adding the sleep API and revising your routine as below.

'(top of module)
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As
Long)


For lCount = StartMachineNo To EndMachineNo
t=timer
sMachineID = "ox" & Right("00" & lCount, 6)

'BOOKMARK

retval = Shell("command.com /c nbtstat -a " & sMachineID & " " &
Environ$("temp") & "\" & sMachineID & ".txt", 0) ' was 6

DoEvents 'every 10 to 20 files would be better but the overhead cause by the
code might not be worth it.
'To many DoEvents will slow the routine down.
That might be a good thing for you.

Sleep (250) 'unless there is a significant delay in the network this
should get trimmed down to ~20ms based on the timer results.

debug.print timer-t

Next lCount


--

John

johnf202 at hotmail dot com


"Tim Childs" wrote in message
...
Hi

in this bit of code is where I originally encountered the problem (see
"BOOKMARK" for workaround) and so limited my self to opening just 10 files
at a time, other wise where the range was large (sometimes 1000, i recall)
the error too many files did appear

I hope I have put in all the called functions - the problem is that it has
never been finished off/tidied up

(Dave, you may seem some of your coding in there somewhere!)

Regards

Tim


Option Explicit
Option Compare Text
Option Base 1

Declare Function GetComputerName& Lib "kernel32" _
Alias "GetComputerNameA" (ByVal lbbuffer As String, nsize As Long)

Public vLineInfo As Variant

Sub IterativeRunNBTstat()

Dim RetVal
Dim Temp
Dim lCount As Long 's/b long?
'Temp = Chr(34) & "<03" & Chr(34) 'for extracting a particular line
Temp = ""

Dim StartMachineNo As Long
Dim EndMachineNo As Long
Dim lTotalNo As Long
Dim sMachineID As String
Dim lLastRow As Long

StartMachineNo = WorksheetFunction.VLookup("StartNumber",
ThisWorkbook.Sheets("Main").Range("A:B"), 2, False)
EndMachineNo = WorksheetFunction.VLookup("EndNumber",
ThisWorkbook.Sheets("Main").Range("A:B"), 2, False)

If EndMachineNo < 1 Then EndMachineNo = StartMachineNo

lTotalNo = EndMachineNo - StartMachineNo + 1

Dim StartTime
StartTime = Now
lLastRow = GetLastRow(2, 2)
Dim iMaxRange
iMaxRange = 10

For lCount = StartMachineNo To EndMachineNo

sMachineID = "ox" & Right("00" & lCount, 6)

'BOOKMARK
If lTotalNo <= iMaxRange Then
ShellAndWait ("command.com /c nbtstat -a " & sMachineID & " " &
Environ$("temp") & "\" & sMachineID & ".txt")
Else '10 more machines, no need for delay while NBTSTAT returns an
answer
RetVal = Shell("command.com /c nbtstat -a " & sMachineID & " "

&
Environ$("temp") & "\" & sMachineID & ".txt", 0) ' was 6
'Application.Wait Now() + TimeValue("00:00:04")
End If
Next lCount

If lTotalNo iMaxRange Then
Do Until Now - StartTime TimeValue("00:00:10")
Debug.Print "waiting"
Application.Wait Now + TimeValue("00:00:02")
Loop
End If

For lCount = StartMachineNo To EndMachineNo
sMachineID = "ox" & Right("00" & lCount, 6)

ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 2) = lCount
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 3) = sGetNameCharsSAT(Environ$("temp") & "\" & sMachineID & ".txt")
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 5) = vLineInfo
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 4) = Now()
Next lCount
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo + 1,
2).Select
Debug.Print Format((Now - StartTime), "hh:mm:ss") & " seconds"
'MsgBox sGetNameCharsSAT("C:\Temp\Test2.txt")
End Sub


Function ReturnName1() As String
Dim z As String * 64
GetComputerName z, 64
ReturnName1 = Left(z, InStr(1, z, Chr(0)) - 1)
End Function

Public Function GetLastRow(FirstCol As Integer, LastCol As Integer) As

Long

Dim ColLastRow As Long
Dim i As Integer

For i = FirstCol To LastCol
ColLastRow = Columns(i).Find("*", , , , , xlPrevious).Row 'Finds data
cells, not formatted ones..
If ColLastRow GetLastRow Then GetLastRow = ColLastRow
Next i

End Function

Function sGetNameCharsSAT(sFullFileName As String)
Dim sOutput
Dim iCounter
Dim iPos
Dim iLineNo As Integer
Dim iFileNum As Integer
Dim strTemp As String
Dim Msg As String
Dim sTemp(20) As String
'Environ$("temp") & "\test2.txt "
'get next available file number
iFileNum = FreeFile
'open the file
'Open "C:\windows\desktop\test.txt" For Input As #iFileNum

If FileExists(sFullFileName) = False Then MsgBox "File " & sFullFileName &

"
NOT FOUND!!"


Open sFullFileName For Input As #iFileNum
'read the entire first line
On Error Resume Next
Line Input #iFileNum, sTemp(1)

If Err.Number = 62 Then
Close #iFileNum
sOutput = "bombed out"
Else
On Error GoTo 0
If Left(sTemp(1), 4) = "Host" Then
'MsgBox "No data found..."
sGetNameCharsSAT = "Machine not logged onto network"
vLineInfo = ""
Close #iFileNum
Exit Function
End If
On Error Resume Next
For iLineNo = 2 To 18
Line Input #iFileNum, sTemp(iLineNo) 'getting the second line

of
input
Next iLineNo
If Err.Number 0 And Err.Number < 62 Then MsgBox "Not normal error -
investigate!!"

On Error GoTo 0
'Range("d6") = sTemp2
For iLineNo = LBound(sTemp, 1) To UBound(sTemp, 1)
Debug.Print iLineNo, sTemp(iLineNo)
Next iLineNo

Close #iFileNum
If Left(sFullFileName, 7) = "C:\Temp" Then Kill sFullFileName
For iCounter = 7 To 18
If InStr(1, sTemp(iCounter), "<03") 0 Then
iPos = InStr(1, sTemp(iCounter), " ")
sOutput = Left(sTemp(iCounter), iPos - 1) '& " Line " &

iCounter
vLineInfo = iCounter '" Line with <03 = " &
'instr(1,
End If
Next iCounter

End If



If sTemp(18) = "" Then sOutput = sOutput & ", line 18 null - NO NT user
logged on"
'prob means machine switched on, no user logged on

sGetNameCharsSAT = sOutput

End Function

Public Function FileExists(StFile As String) As Boolean
FileExists = False
On Error Resume Next
If Dir(StFile) < "" Then
If Err.Number = 68 Then 'what is Error 68 - look it up
Err.Clear
On Error GoTo 0
Exit Function
Else
FileExists = True
End If
End If
End Function




"jaf" wrote in message
...
Hi Dave,
It addresses open file resources for all the major o/s's.
I spent awhile on google and saw several mentions of the old "out of

memory"
problem being traced to "to many open files"

There are several API windows error message constants dealing with "to

many
open files", but I didn't see anything about querying for available

files.
There must be some or windows wouldn't need an error message.


--

John

johnf202 at hotmail dot com







  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default "Headroom" on <Files=99 in config.sys

Hi

so is it the case that the problem I encountered is a "mirage" and that it
does not happen on (most) other machines?

regards

Tim

"Tim Childs" wrote in message
...
Hi

in this bit of code is where I originally encountered the problem (see
"BOOKMARK" for workaround) and so limited my self to opening just 10 files
at a time, other wise where the range was large (sometimes 1000, i recall)
the error too many files did appear

I hope I have put in all the called functions - the problem is that it has
never been finished off/tidied up

(Dave, you may seem some of your coding in there somewhere!)

Regards

Tim


Option Explicit
Option Compare Text
Option Base 1

Declare Function GetComputerName& Lib "kernel32" _
Alias "GetComputerNameA" (ByVal lbbuffer As String, nsize As Long)

Public vLineInfo As Variant

Sub IterativeRunNBTstat()

Dim RetVal
Dim Temp
Dim lCount As Long 's/b long?
'Temp = Chr(34) & "<03" & Chr(34) 'for extracting a particular line
Temp = ""

Dim StartMachineNo As Long
Dim EndMachineNo As Long
Dim lTotalNo As Long
Dim sMachineID As String
Dim lLastRow As Long

StartMachineNo = WorksheetFunction.VLookup("StartNumber",
ThisWorkbook.Sheets("Main").Range("A:B"), 2, False)
EndMachineNo = WorksheetFunction.VLookup("EndNumber",
ThisWorkbook.Sheets("Main").Range("A:B"), 2, False)

If EndMachineNo < 1 Then EndMachineNo = StartMachineNo

lTotalNo = EndMachineNo - StartMachineNo + 1

Dim StartTime
StartTime = Now
lLastRow = GetLastRow(2, 2)
Dim iMaxRange
iMaxRange = 10

For lCount = StartMachineNo To EndMachineNo

sMachineID = "ox" & Right("00" & lCount, 6)

'BOOKMARK
If lTotalNo <= iMaxRange Then
ShellAndWait ("command.com /c nbtstat -a " & sMachineID & " " &
Environ$("temp") & "\" & sMachineID & ".txt")
Else '10 more machines, no need for delay while NBTSTAT returns an
answer
RetVal = Shell("command.com /c nbtstat -a " & sMachineID & " "

&
Environ$("temp") & "\" & sMachineID & ".txt", 0) ' was 6
'Application.Wait Now() + TimeValue("00:00:04")
End If
Next lCount

If lTotalNo iMaxRange Then
Do Until Now - StartTime TimeValue("00:00:10")
Debug.Print "waiting"
Application.Wait Now + TimeValue("00:00:02")
Loop
End If

For lCount = StartMachineNo To EndMachineNo
sMachineID = "ox" & Right("00" & lCount, 6)

ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 2) = lCount
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 3) = sGetNameCharsSAT(Environ$("temp") & "\" & sMachineID & ".txt")
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 5) = vLineInfo
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo +
1, 4) = Now()
Next lCount
ThisWorkbook.Sheets("Main").Cells(lLastRow + lCount - StartMachineNo + 1,
2).Select
Debug.Print Format((Now - StartTime), "hh:mm:ss") & " seconds"
'MsgBox sGetNameCharsSAT("C:\Temp\Test2.txt")
End Sub


Function ReturnName1() As String
Dim z As String * 64
GetComputerName z, 64
ReturnName1 = Left(z, InStr(1, z, Chr(0)) - 1)
End Function

Public Function GetLastRow(FirstCol As Integer, LastCol As Integer) As

Long

Dim ColLastRow As Long
Dim i As Integer

For i = FirstCol To LastCol
ColLastRow = Columns(i).Find("*", , , , , xlPrevious).Row 'Finds data
cells, not formatted ones..
If ColLastRow GetLastRow Then GetLastRow = ColLastRow
Next i

End Function

Function sGetNameCharsSAT(sFullFileName As String)
Dim sOutput
Dim iCounter
Dim iPos
Dim iLineNo As Integer
Dim iFileNum As Integer
Dim strTemp As String
Dim Msg As String
Dim sTemp(20) As String
'Environ$("temp") & "\test2.txt "
'get next available file number
iFileNum = FreeFile
'open the file
'Open "C:\windows\desktop\test.txt" For Input As #iFileNum

If FileExists(sFullFileName) = False Then MsgBox "File " & sFullFileName &

"
NOT FOUND!!"


Open sFullFileName For Input As #iFileNum
'read the entire first line
On Error Resume Next
Line Input #iFileNum, sTemp(1)

If Err.Number = 62 Then
Close #iFileNum
sOutput = "bombed out"
Else
On Error GoTo 0
If Left(sTemp(1), 4) = "Host" Then
'MsgBox "No data found..."
sGetNameCharsSAT = "Machine not logged onto network"
vLineInfo = ""
Close #iFileNum
Exit Function
End If
On Error Resume Next
For iLineNo = 2 To 18
Line Input #iFileNum, sTemp(iLineNo) 'getting the second line

of
input
Next iLineNo
If Err.Number 0 And Err.Number < 62 Then MsgBox "Not normal error -
investigate!!"

On Error GoTo 0
'Range("d6") = sTemp2
For iLineNo = LBound(sTemp, 1) To UBound(sTemp, 1)
Debug.Print iLineNo, sTemp(iLineNo)
Next iLineNo

Close #iFileNum
If Left(sFullFileName, 7) = "C:\Temp" Then Kill sFullFileName
For iCounter = 7 To 18
If InStr(1, sTemp(iCounter), "<03") 0 Then
iPos = InStr(1, sTemp(iCounter), " ")
sOutput = Left(sTemp(iCounter), iPos - 1) '& " Line " &

iCounter
vLineInfo = iCounter '" Line with <03 = " &
'instr(1,
End If
Next iCounter

End If



If sTemp(18) = "" Then sOutput = sOutput & ", line 18 null - NO NT user
logged on"
'prob means machine switched on, no user logged on

sGetNameCharsSAT = sOutput

End Function

Public Function FileExists(StFile As String) As Boolean
FileExists = False
On Error Resume Next
If Dir(StFile) < "" Then
If Err.Number = 68 Then 'what is Error 68 - look it up
Err.Clear
On Error GoTo 0
Exit Function
Else
FileExists = True
End If
End If
End Function




"jaf" wrote in message
...
Hi Dave,
It addresses open file resources for all the major o/s's.
I spent awhile on google and saw several mentions of the old "out of

memory"
problem being traced to "to many open files"

There are several API windows error message constants dealing with "to

many
open files", but I didn't see anything about querying for available

files.
There must be some or windows wouldn't need an error message.


--

John

johnf202 at hotmail dot com







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
correct syntax for nesting "if", "and", and "vlookup"....if possib Christine Excel Worksheet Functions 4 January 2nd 09 10:43 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 09:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"