Actually Loading the Script FileNow that we've got all of our storage structures created, we can actually load our script file. Put this function into your class module: An explanation!Hopefully the comments in the code for the LoadScriptFile function are sufficient to explain what the more confusing lines do. The use of string manipulation functions such as InStr, Left$, and Right$ can become very confusing if you have not used them before, or don't know how they work. Therefore, if you wish to truly understand how the string parsing works, I suggest you read up on these functions, and other related ones including Mid and Split. Until next time...By now, you should understand how to load and store your script files on disk and in memory. This is the most important piece, and can be the most complicated. The actual loading and splitting up of the individual lines is integral to the use of your scripting engine, and thus you have to make absolutely sure that it is foolproof (or as close to this as possible!). I suggest adding error handlers, and using the return value of LoadScriptFile to check whether the file was loaded correctly when you call it. In the next article in this series, the actual use of your scripting will be discussed. The third part of this series will then continue along that theme and go into much more depth with the implementation, including a section on interfacing the scripting engine with a tile-based system in order to create events. Source CodeThough simple, if you would like the source code to this part of the series, the class module is available at: [ http://blackhole.thenexus.bc.ca/articles/CScriptParser.cls ] Contact + Future ReleasesUpdated versions of this article, as well as the later parts of the series as they are written, will be available from my website, the black hole. [ http://blackhole.thenexus.bc.ca/ ] I can be reached for comments or questions at I sincerely hope you've gained from this article, and look forward to the next part of the series! David Goodlad
|