Everybody,
Okay, here it is. Everybody will immediately see that I have returned to procedural methods to set this up. My excuse for not using the new objects is that I have been working closely with Mr. Murphy and you know how that goes.
I've included everything needed to add messages and the prototypes for the two functions required to send and receive messages. These functions are in Tokenizer.bas under "Helper Functions". Using the gMessageQueue() array seemed the simplest way to keep track.
New messages are appended to the end of the array. When a module checks for its own messages the first message in the queue addressed to the calling module is returned and deleted from the array. So it is important that the module retrieving messages act on them. As I am thinking about it, the action could be as simple as adding an acknowledgment to the queue or as complex as converting an entire VB project. Tried to make it flexible.
gVbCodeBlock is a global that should only be set by the Editor since that is the main user interface. Once gPbCodeBlock is filled, the Tokenizer will send a message back to the Editor that it's done.
The list of equates at the end is provided for information. If it gives you any ideas for messages, that's good.
Mike,
As I review this for posting, I noticed that there's no special allowance for the code your GUI converter will produce. Do you think we need a separate STRING codeblock for the GUI code output or can both the GUI converter and the Tokenizer use the same string space for output? Sorry, I didn't think about that when putting this together.
Stan
Okay, here it is. Everybody will immediately see that I have returned to procedural methods to set this up. My excuse for not using the new objects is that I have been working closely with Mr. Murphy and you know how that goes.

I've included everything needed to add messages and the prototypes for the two functions required to send and receive messages. These functions are in Tokenizer.bas under "Helper Functions". Using the gMessageQueue() array seemed the simplest way to keep track.
New messages are appended to the end of the array. When a module checks for its own messages the first message in the queue addressed to the calling module is returned and deleted from the array. So it is important that the module retrieving messages act on them. As I am thinking about it, the action could be as simple as adding an acknowledgment to the queue or as complex as converting an entire VB project. Tried to make it flexible.
gVbCodeBlock is a global that should only be set by the Editor since that is the main user interface. Once gPbCodeBlock is filled, the Tokenizer will send a message back to the Editor that it's done.
The list of equates at the end is provided for information. If it gives you any ideas for messages, that's good.
Code:
'The gMessageQueue() TYPE MessageType SentTo AS LONG '%Editor or %Converter or %MikesGUIThingy SentFrom AS LONG '%Editor or %Converter or %MikesGUIThingy MsgID AS LONG 'a value from the message INI file ' ie., from one of INFO, WARNING, ERROR, FATALERROR groups ' (see below under Message Equates) END TYPE 'MessageQueue FUNCTIONS '%True = message successfully added to MessageQueue DECLARE FUNCTION PostVB2PBMessage(SentTo AS LONG, SentFrom AS LONG, MsgID AS LONG) AS LONG 'call with SentTo set to self (%Editor, %Converter, %MikesGUIThingy) DECLARE SUB GetNextVB2PBMessage(SentTo AS LONG, SentFrom AS LONG, MsgID AS LONG) 'Relevant GLOBALS in Tokenizer: 'Editor/Converter Message Queue GLOBAL gMessages() AS MessageType 'message queue GLOBAL gVbCodeBlock AS STRING 'VB6 code to be converted GLOBAL gPbCodeBlock AS STRING 'converted PBWin code GLOBAL gTokenizerStatus AS LONG 'current program status, can be checked from any module 'internal TokenizerStatus equates %IsPaused = 560 %IsReady = 561 %IsRunning = 562 %IsFinished = 563 %IsSearching = 564 %IsEditing = 565 %IsBrowsing = 566 %Saved_WIP = 580 'EQUATES 'module IDs for intenal messaging -- use these in SentTo and SentFrom params %Editor = 628 %Converter = 629 %MikesGUIThingy = 630 'Message Equates ' This is set up as a flat INI file (per John). Anybody can add to this list. ' NOTE: %RequestStatus is removed because gTokenizerStatus is updated internally ' by the Tokenizer and available to any module. ' %BlockConverted is deprecated because the Tokenizer will convert whatever ' the Editor puts into gVbCodeBlock. Editor decides how much code to convert. ' (Note to John: Tokenizer expects $CRLF as a line delimiter and will return ' gPbCodeBlock with $CRLF line delimiters.) ' Editor/Converter/GUI Messages: ' %Info: 1101 - 1200 'implied message that ConverterCOM class is ready to be processed %NewCodePosted = 1101 'editor to converter: ' ConverterCOM class has been updated with new VB code %DoNotProcessEntireProject = 1103 'editor to converter: ' do not parse entire VB project, only the code I send you 'implied message that ConverterCOM class contains PB code for editor to access %Converted = 1110 'converter to editor: ' gPbCodeBlock has been updated with new PB code %ParsingProjectFiles = 1112 'converter to editor: VB Project files are being parsed preparatory to processing ' %Warning: 1201 - 1400 %OptionExplicit_NotFound = 1201 'VB module without OPTION EXPLICIT (obnoxious comment required) ' %Error: 1401 - 1600 %VB_SourceCorrupted = 1401 'converter cannot read the VB source code %VB_StructureWithoutEND = 1402 'converter found a FUNCTION, SUB, CLASS, METHOD, PROPERTY, EVENT without END ' %FatalError: 1601 - 1800 %UndefinedFatalError = 1601 'duh... I think its broke somewhere. ' *** Numbers used internally = 501-630 as of 9/5/2008 *** ' *** Numbers reserverd = 1100 - 1900 for messages - see list above for values *** ' *** values 601-615 are NOT used by vb2pb v1 - internal PB8 compiler errors) *** 'OTHER EQUATES 'These equates are defined in vb2pbEquates.inc and can be used to describe terms 'in communication between the editor and the converter. 'PBWin variable types & term descriptors %pbByte %pbInteger %pbLong %pbQuad %pbWord %pbDword %pbSingle %pbDouble %pbExtended %pbCurrency %pbExtendedCurrency %pbString %pbFixedLengthString %pbAscizString %pbFieldString %pbGUID %pbVariant %pbUserDefinedType %pbArray %pbObject %pbNumericLiteral %pbStringLiteral %pbNumericEquate %pbStringEquate %pbCompilerDirective %pbOperator %pbKeyword %pbFunctionPrototype %pbSubPrototype %pbMethodPrototype %pbComment 'VB6 variable types & term descriptors %vbBoolean %vbByte %vbConst %vbCurrency %vbDouble %vbInteger %vbLong %vbSingle %vbString %vbFixedLengthString %vbVariant %vbUserDefinedType %vbArray %vbObject %vbCollection %vbProperty %vbFunction %vbMethod %vbEvent %vbStatement %vbKeyword %vbConstant %vbOperator %vbControl %vbActiveXControl %vbCompilerDirective %vbComment 'VB Class, Properties, Methods, & Events %vbClassPrototype %vbMethodPrototype %vbFunctionPrototype %vbSubPrototype 'variable scope equates %vbGlobal %vbModule %vbStatic %vbLocal %vbPrivate %vbPublic %pbGlobal %pbStatic %pbLocal %pbInstance 'VB Class equates - identify specific parts of a VB class %ClassDefinition %EndClassDefinition %PropertyDefinition %EndPropertyDefinition %MethodDefinition %EndMethodDefinition %EventDefinition %EndEventDefinition %SubClassDefinition %EndSubClassDefinition %FunctionDefinition %EndFunctionDefinition %SubDefinition %EndSubDefinition %TypeDefinition %EndTypeDefinition %EnumDefinition %EndEnumDefinition $Separator = "|" 'long string data separator = pipe character ' (note: SEPARATOR is a secondary reserved word, ' name may have to change in version 2 - sjh)
As I review this for posting, I noticed that there's no special allowance for the code your GUI converter will produce. Do you think we need a separate STRING codeblock for the GUI code output or can both the GUI converter and the Tokenizer use the same string space for output? Sorry, I didn't think about that when putting this together.
Stan
Comment