Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A func.bas makes a func.exe - Can I Call(SHELL?) to func.exe?
#1
Sub: A func.bas makes a func.exe - Can I SHELL to func.exe?  Yes I can, but it is SLOW.  My func.bas program is msecs.bas, which gets milliseconds since midnight.

Program 1 shows that the API call is FAST.  BUT I don't want to have all the baggage (Type..End Type, Declare..EndDeclare, Function..EndFunction), I'd rather compile it and call (SHELL?) it.


Code: (Select All)
_Title "Test IncodeMsecs"
Option _Explicit
DefLng A-Z

Type typeTime
  yr As Integer
  mo As Integer
  ddWk As Integer
  dd As Integer
  hh As Integer
  mm As Integer
  ss As Integer
  ms As Integer
End Type

Declare Dynamic Library "Kernel32"
  Sub GetSystemTime (lpSystemTime As typeTime)
End Declare

Dim i, nloops, ms0 ' start
For i = 1 To 20
  ms0 = IncodeMsecs
  Do Until IncodeMsecs <> ms0: Loop ' start a new ms
  nloops = 0 ' start counting
  ms0 = IncodeMsecs ' during this 1 ms
  Do Until IncodeMsecs <> ms0: nloops = nloops + 1: Loop
  Print nloops; " loops in 1 millisecond"
Next i

Function IncodeMsecs () ' This is FAST, but how to compile it and use it as an exe file?
  Dim sysTime As typeTime, hh, mm, ss, ms
  GetSystemTime sysTime
  hh = sysTime.hh
  mm = sysTime.mm
  ss = sysTime.ss
  ms = sysTime.ms
  IncodeMsecs = ms + 1000 * (ss + 60 * (mm + 60 * hh))
End Function

Program 2 is THE msecs.bas (with the baggage) which makes msecs.exe which returns milliseconds:

Code: (Select All)
_Title "msecs"
Option _Explicit
DefLng A-Z

Type typeTime
  yr As Integer
  mo As Integer
  ddWk As Integer
  dd As Integer
  hh As Integer
  mm As Integer
  ss As Integer
  ms As Integer
End Type

Declare Dynamic Library "Kernel32"
  Sub GetSystemTime (lpSystemTime As typeTime)
End Declare

Dim Shared sysTime As typeTime
GetSystemTime sysTime
Dim hh, mm, ss, ms
hh = sysTime.hh
mm = sysTime.mm
ss = sysTime.ss
ms = sysTime.ms
System ms + 1000 * (ss + 60 * (mm + 60 * hh))

Program 3 (without the baggage) shows that IT WORKS, but is SLOW.  You spend 1000 ms to get the current ms.

Code: (Select All)
_Title "Test2 msecs"
Option _Explicit
DefLng A-Z

Print Shell("msecs") ' SLOW!
Print Shell("msecs")
Print Shell("msecs")
Print Shell("msecs")
Print Shell("msecs")
Print Shell("msecs")
Print Shell("msecs")
Print Shell("msecs")
Print Shell("msecs")
Print Shell("msecs")

1) I don't want to hear about something like that _Millisecs() already exists -- I want to pursue doing this. [ I found out about Timer(.001) ! ]
2) Apparently msecs.exe is not staying in memory - is being re-loaded each call.
3) Apparently msecs.exe is opening/closing an unused/unwanted console window.
4) This makes it SLOW.  Can I fix these issues?

I would appreciate your solutions.
Reply


Messages In This Thread
A func.bas makes a func.exe - Can I Call(SHELL?) to func.exe? - by dcromley - 05-13-2022, 07:26 PM



Users browsing this thread: 1 Guest(s)