View Single Post
Old 03-14-2006   #83 (permalink)
goldfndr
Knight Tooth Puller
 
goldfndr's Avatar
 
Join Date: Aug 2004
Location: Bellevue, WA, USA
Posts: 182
Believe it or not, I already anticipated this issue a week or two ago. The newest version of the subroutine will be as follows:
Code:
Private Sub IncludeFile(FileName)
' Includes a file in the global namespace of the current script.
' The file can contain any VBScript source code.
	if not FSO.FileExists(FileName) then
		MsgBox FileName & " does not exist!" & vbCRLF _
		  & "Please extract to " & nameDir & "!", vbCritical, nameScript
		WScript.Quit
	end if
	set f = FSO.OpenTextFile(FileName, ForReading)
	ExecuteGlobal f.ReadAll()
	f.Close
End Sub
OTOH, maybe nameDir isn't being set to the ns04master.vbs's folder, I need to check that. It OUGHT to be able to run from any folder (as long as all are extracted there), but it sounds like something broke there. I'll test, thanks.

I've also cleaned up MapPoint (finally), I just hope I didn't break anything (but I'm confident TPEER will step in if I did). There's no longer an Initialized variable or an Initialize subroutine, it's all in-line and more modular. The previous (20060228-) code was checking Initialized in every OnGPSPosition and every OnPositionChange, which seemed horribly wasteful. I couldn't envision a reason not to just perform it once (at the start) and get it over with. Well, maybe it's too slow... but then, everyone should theoretically be starting NetStumbler while not in motion, right? Even if it was slow, any event processing that isn't threaded (heh) halts all NetStumbler processing, otherwise there would've been a reentrancy problem with Initialize being called simultaneously... sorry, just rambling here, sleep deprivation...

The new code also splits ns04master.vbs into two files - a second file, ns04subcalls.vbs (I'm really not sure that that's a good name, maybe ns04events.vbs would be better? Any suggestions?) has each of the event handler subroutines called directly by NetStumbler, which each in turn call the modules' event handling subroutines. ns04master.vbs, which is much smaller without the primary event handler subroutines, does ReadAll on it then Filters it for the Usemodule statements that are False. The result is that it's effectively preprocessed. So, for example, if you aren't using SubStation support, no "If UseSubstation" checks are performed due to being filtered out. Slightly faster code!

I've also unified the GPS variables (OldLat, OldLon, NowLat, NowLon, NowAlt) - many module-specific variables are gone now, and code is simplified, although admittedly the OnGPSPosition code (which sets all five) might be a bit slower now. I'm currently working on eliminating passed arguments (e.g. OnGPSPositionmodule calls no longer pass parameters because the subroutines use the variables). OnScanCompletemodule calls will change radically due to most parameters being ignored (and thus not needing to be passed).
goldfndr is offline   Reply With Quote