Loading ...
Sorry, an error occurred while loading the content.

How do you write a branch macro command

Expand Messages
  • Larry
    Everyone, Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR. Say you want a IFNUM where if the
    Message 1 of 9 , Jul 19, 2010
    • 0 Attachment
      Everyone,

      Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.

      Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?

      So, is it as simple as ...

      bool XPCALL Command(int Result, int Result1, int Result2)

      Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?

      Or is it more complicated then that?

      L. Lee Saunders
    • Mike Riddle
      Here is the code that ends the IFERR command, showing taking the branch or not: WasErr: test IfErrFlag,1 ;was an error flagged? jz abort ;
      Message 2 of 9 , Jul 19, 2010
      • 0 Attachment
        Here is the code that ends the IFERR command, showing taking
        the branch or not:

        WasErr: test IfErrFlag,1 ;was an error flagged?
        jz abort
        ;
        doGo: SVC GoToLabel,<offset LblName>
        abort: SVC CmdEnd

        Mike

        On 7/19/2010 12:08 PM, Larry wrote:
        > Everyone,
        >
        > Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.
        >
        > Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?
        >
        > So, is it as simple as ...
        >
        > bool XPCALL Command(int Result, int Result1, int Result2)
        >
        > Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?
        >
        > Or is it more complicated then that?
        >
        > L. Lee Saunders
        >
        >
        >
        > ------------------------------------
        >
        > To Post a message, send it to: cc2-dev-l@...
        > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...! Groups Links
        >
        >
        >
        >
      • L. Lee Saunders
        Thanks Mike. You wouldn t happen to have an example in C, would you? I have not written assembly in 15+ years, and that was risc assembly at that. L. Lee
        Message 3 of 9 , Jul 20, 2010
        • 0 Attachment
          Thanks Mike. You wouldn't happen to have an example in C, would you?  I have not written assembly in 15+ years, and that was risc assembly at that.

          L. Lee Saunders
            
          Here is the code that ends the IFERR command, showing taking
          the branch or not:

          WasErr: test IfErrFlag,1 ;was an error flagged?
          jz abort
          ;
          doGo: SVC GoToLabel,<offset LblName>
          abort: SVC CmdEnd

          Mike

          On 7/19/2010 12:08 PM, Larry wrote:
          > Everyone,
          >
          > Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.
          >
          > Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?
          >
          > So, is it as simple as ...
          >
          > bool XPCALL Command(int Result, int Result1, int Result2)
          >
          > Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?
          >
          > Or is it more complicated then that?
          >
          > L. Lee Saunders
          >
          >
          >
          > ------------------------------------
          >
          > To Post a message, send it to: cc2-dev-l@...
          > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...! Groups Links
          >
          >
          >
          >




          Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.
        • L. Lee Saunders
          Mike, In walking through your code - in an attempt to understand it - I noticed you are making an API Service call (SVC) to the API command GoToLabel. Yet in
          Message 4 of 9 , Jul 20, 2010
          • 0 Attachment
            Mike,
             
            In walking through your code - in an attempt to understand it - I noticed you are making an API Service call (SVC) to the API command GoToLabel.  Yet in walking through XPSVC.CPY, I cannot find a reference to GoToLabel.  I even did a search of the entire Toolkit and I could not find it.
             
            Any help would be appreciated.
             
            Thanks,
            Lee
              

            Here is the code that ends the IFERR command, showing taking
            the branch or not:

            WasErr: test IfErrFlag,1 ;was an error flagged?
            jz abort
            ;
            doGo: SVC GoToLabel,<offset LblName>
            abort: SVC CmdEnd

            Mike

            On 7/19/2010 12:08 PM, Larry wrote:
            > Everyone,
            >
            > Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.
            >
            > Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?
            >
            > So, is it as simple as ...
            >
            > bool XPCALL Command(int Result, int Result1, int Result2)
            >
            > Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?
            >
            > Or is it more complicated then that?
            >
            > L. Lee Saunders
            >
            >
            >
            > ------------ --------- --------- ------
            >
            > To Post a message, send it to: cc2-dev-l@eGroups. com
            > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscri be@eGroups. comYahoo! Groups Links
            >
            >
            >
            >




            Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.



            The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. Get busy.
          • Peter Olsson
            I don’t think GoToLabel is exported. The easiest workaround is to write a TESTNUM command and then use IFERR to do the jump in the macro. (The code below is
            Message 5 of 9 , Jul 20, 2010
            • 0 Attachment

              I don’t think GoToLabel is exported. The easiest workaround is to write a TESTNUM command and then use IFERR to do the jump in the macro.

              (The code below is not tested so will probably contain a few errors, but should give you the general idea.)

               

              The macro would be:

               

              MACRO CheckInput

              GL;var;^DUser input:

              IFERR UserCancel

              TESTNUM;var

              IFERR NotANumber

              GL;comment;Run code for numbers

              :NotANumber

              GL;comment;Run code for numbers and non-numbers

              :UserCancel

              ENDM

               

              The actual XP command would be:

               

              DWORD * XPCALL GetErrFlagAdr(void);

               

              ////////////////////////////////////////////////////////////////

               

              void XPCALL TestNumCmd1(int Result, int Result1, int Result2);

               

              static char TestNumCmdStr[128];

               

              FORMST(lpszTestNumCmd1, "Text: ")

               

              RDATA rTestNumCmd1 = {sizeof(RDATA), RD_TxWord, NULL, RDF_C | RDF_SPACEOK, (DWORD *)TestNumCmdStr,

              (DWORD *)&lpszTestNumCmd1, RDC_ARROW, TestNumCmd1, NULL, NULL, 0, NULL, 0};

               

              void XPCALL TestNumCmd(void)

              {

                ReqData(&rTestNumCmd1);

               

              void XPCALL TestNumCmd1(int Result, int Result1, int Result2)

              {

                DWORD *pMacroErrFlag=GetErrFlagAdr();

                char *p;

               

                if(Result==X_OK)

                {

                  for(p=TestNumCmdStr; *p; p++)

                    if(*p<'0' || *p>'9')

                      break;

               

                  *pMacroErrFlag = *p!=’\0’;

                }

                else

                  *pMacroErrFlag = TRUE;

               

                CmdEnd();

              }

               

               

              Peter

               

              Från: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] För L. Lee Saunders
              Skickat: den 20 juli 2010 16:56
              Till: dev
              Ämne: RE: [cc2-dev-l] How do you write a branch macro command

               

               

              Mike,
               
              In walking through your code - in an attempt to understand it - I noticed you are making an API Service call (SVC) to the API command GoToLabel.  Yet in walking through XPSVC.CPY, I cannot find a reference to GoToLabel.  I even did a search of the entire Toolkit and I could not find it.
               
              Any help would be appreciated.
               
              Thanks,
              Lee
                

              Here is the code that ends the IFERR command, showing taking
              the branch or not:

              WasErr: test IfErrFlag,1 ;was an error flagged?
              jz abort
              ;
              doGo: SVC GoToLabel,<offset LblName>
              abort: SVC CmdEnd

              Mike

              On 7/19/2010 12:08 PM, Larry wrote:
              > Everyone,
              >
              > Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.
              >
              > Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?
              >
              > So, is it as simple as ...
              >
              > bool XPCALL Command(int Result, int Result1, int Result2)
              >
              > Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?
              >
              > Or is it more complicated then that?
              >
              > L. Lee Saunders
              >
              >
              >
              > ------------------------------------
              >
              > To Post a message, send it to: cc2-dev-l@...
              > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...! Groups Links
              >
              >
              >
              >

               


              Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.

               

               


              The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. Get busy.

            • L. Lee Saunders
              Thanks Peter, I was beginning to think this may not be possible. So, it boils down to: Calling my command first, then if I’ve set an error, the Macro IFERR
              Message 6 of 9 , Jul 20, 2010
              • 0 Attachment

                Thanks Peter, I was beginning to think this may not be possible.  So, it boils down to:

                 

                Calling my command first, then if I’ve set an error, the Macro IFERR will see it and jump to the error condition.  Where as if my command passes the input (ie, I do NOT set the error flag) the Macro just continues to run without a jump.

                 

                So, for this example the best name for the command would be: ERRIFNOTNUM, ERR_IF_NOT_NUM, SETERRIFNOTNUM or SET_ERR_IF_NOT_NUM

                 

                Any preferences from the Macro programmers out there?  I’m looking for a generic naming convention:

                 

                So, if I wrote a command that took two lines and compared their angles (Not that I’m going to write such a command – I’m just using it as an example), would the best name be:

                 

                1-      ERRIFNOTEQANGLE

                2-      ERR_IF_NOT_EQ_ANGLE

                3-      SET\ERRIFNOTEQANGLE

                4-      SET_ERR_IF_NOT_EQ_ANGLE

                 

                Any Votes, one way or another?

                 

                Lee

                 

                From: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] On Behalf Of Peter Olsson
                Sent: Tuesday, July 20, 2010 12:51 PM
                To: cc2-dev-l@yahoogroups.com
                Subject: Re: [cc2-dev-l] How do you write a branch macro command

                 

                 

                I don’t think GoToLabel is exported. The easiest workaround is to write a TESTNUM command and then use IFERR to do the jump in the macro.

                (The code below is not tested so will probably contain a few errors, but should give you the general idea.)

                 

                The macro would be:

                 

                MACRO CheckInput

                GL;var;^DUser input:

                IFERR UserCancel

                TESTNUM;var

                IFERR NotANumber

                GL;comment;Run code for numbers

                :NotANumber

                GL;comment;Run code for numbers and non-numbers

                :UserCancel

                ENDM

                 

                The actual XP command would be:

                 

                DWORD * XPCALL GetErrFlagAdr(void);

                 

                ////////////////////////////////////////////////////////////////

                 

                void XPCALL TestNumCmd1(int Result, int Result1, int Result2);

                 

                static char TestNumCmdStr[128];

                 

                FORMST(lpszTestNumCmd1, "Text: ")

                 

                RDATA rTestNumCmd1 = {sizeof(RDATA), RD_TxWord, NULL, RDF_C | RDF_SPACEOK, (DWORD *)TestNumCmdStr,

                (DWORD *)&lpszTestNumCmd1, RDC_ARROW, TestNumCmd1, NULL, NULL, 0, NULL, 0};

                 

                void XPCALL TestNumCmd(void)

                {

                  ReqData(&rTestNumCmd1);

                 

                void XPCALL TestNumCmd1(int Result, int Result1, int Result2)

                {

                  DWORD *pMacroErrFlag=GetErrFlagAdr();

                  char *p;

                 

                  if(Result==X_OK)

                  {

                    for(p=TestNumCmdStr; *p; p++)

                      if(*p<'0' || *p>'9')

                        break;

                 

                    *pMacroErrFlag = *p!=’\0’;

                  }

                  else

                    *pMacroErrFlag = TRUE;

                 

                  CmdEnd();

                }

                 

                 

                Peter

                 

                Från: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] För L. Lee Saunders
                Skickat: den 20 juli 2010 16:56
                Till: dev
                Ämne: RE: [cc2-dev-l] How do you write a branch macro command

                 

                 

                Mike,
                 
                In walking through your code - in an attempt to understand it - I noticed you are making an API Service call (SVC) to the API command GoToLabel.  Yet in walking through XPSVC.CPY, I cannot find a reference to GoToLabel.  I even did a search of the entire Toolkit and I could not find it.
                 
                Any help would be appreciated.
                 
                Thanks,
                Lee
                  

                Here is the code that ends the IFERR command, showing taking
                the branch or not:

                WasErr: test IfErrFlag,1 ;was an error flagged?
                jz abort
                ;
                doGo: SVC GoToLabel,<offset LblName>
                abort: SVC CmdEnd

                Mike

                On 7/19/2010 12:08 PM, Larry wrote:
                > Everyone,
                >
                > Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.
                >
                > Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?
                >
                > So, is it as simple as ...
                >
                > bool XPCALL Command(int Result, int Result1, int Result2)
                >
                > Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?
                >
                > Or is it more complicated then that?
                >
                > L. Lee Saunders
                >
                >
                >
                > ------------------------------------
                >
                > To Post a message, send it to: cc2-dev-l@...
                > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...! Groups Links
                >
                >
                >
                >

                 


                Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.

                 

                 


                The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. Get busy.

              • L. Lee Saunders
                Am I missing a reference? unresolved external symbol unsigned long * __stdcall GetErrFlagAdr(void) L. Lee Saunders It was only a partial solution, of
                Message 7 of 9 , Jul 20, 2010
                • 0 Attachment
                  Am I missing a reference?
                   
                  unresolved external symbol "unsigned long * __stdcall GetErrFlagAdr(void)"

                  L. Lee Saunders
                   
                  "It was only a partial solution, of course, as solutions usually are, and addressed only one specific problem, as solutions usually do. But, as was often also true, it opened the door—if only a crack—for the multitude of solutions to follow." 
                  1632 - Eric Flint
                   
                  my blog: http://oldschooldotnet.blogspot.com
                  Taking Dot Net "Old School" - Playing with old ideas/concepts using the newest tools!
                   
                   




                   

                  To: cc2-dev-l@yahoogroups.com
                  From: saunderl@...
                  Date: Tue, 20 Jul 2010 14:38:45 -0500
                  Subject: RE: [cc2-dev-l] How do you write a branch macro command

                   

                  Thanks Peter, I was beginning to think this may not be possible.  So, it boils down to:

                   

                  Calling my command first, then if I’ve set an error, the Macro IFERR will see it and jump to the error condition.  Where as if my command passes the input (ie, I do NOT set the error flag) the Macro just continues to run without a jump.

                   

                  So, for this example the best name for the command would be: ERRIFNOTNUM, ERR_IF_NOT_NUM, SETERRIFNOTNUM or SET_ERR_IF_NOT_ NUM

                   

                  Any preferences from the Macro programmers out there?  I’m looking for a generic naming convention:

                   

                  So, if I wrote a command that took two lines and compared their angles (Not that I’m going to write such a command – I’m just using it as an example), would the best name be:

                   

                  1-      ERRIFNOTEQANGLE

                  2-      ERR_IF_NOT_EQ_ ANGLE

                  3-      SET\ERRIFNOTEQANGLE

                  4-      SET_ERR_IF_NOT_ EQ_ANGLE

                   

                  Any Votes, one way or another?

                   

                  Lee

                   

                  From: cc2-dev-l@yahoogrou ps.com [mailto:cc2- dev-l@yahoogroup s.com] On Behalf Of Peter Olsson
                  Sent: Tuesday, July 20, 2010 12:51 PM
                  To: cc2-dev-l@yahoogrou ps.com
                  Subject: Re: [cc2-dev-l] How do you write a branch macro command

                   

                   

                  I don’t think GoToLabel is exported. The easiest workaround is to write a TESTNUM command and then use IFERR to do the jump in the macro.

                  (The code below is not tested so will probably contain a few errors, but should give you the general idea.)

                   

                  The macro would be:

                   

                  MACRO CheckInput

                  GL;var;^DUser input:

                  IFERR UserCancel

                  TESTNUM;var

                  IFERR NotANumber

                  GL;comment;Run code for numbers

                  :NotANumber

                  GL;comment;Run code for numbers and non-numbers

                  :UserCancel

                  ENDM

                   

                  The actual XP command would be:

                   

                  DWORD * XPCALL GetErrFlagAdr( void);

                   

                  //////////// ///////// ///////// ///////// ///////// ///////// ///////

                   

                  void XPCALL TestNumCmd1( int Result, int Result1, int Result2);

                   

                  static char TestNumCmdStr[ 128];

                   

                  FORMST(lpszTestNumC md1, "Text: ")

                   

                  RDATA rTestNumCmd1 = {sizeof(RDATA) , RD_TxWord, NULL, RDF_C | RDF_SPACEOK, (DWORD *)TestNumCmdStr,

                  (DWORD *)&lpszTestNumCmd1, RDC_ARROW, TestNumCmd1, NULL, NULL, 0, NULL, 0};

                   

                  void XPCALL TestNumCmd(void)

                  {

                    ReqData(&rTestNumCmd1) ;

                   

                  void XPCALL TestNumCmd1( int Result, int Result1, int Result2)

                  {

                    DWORD *pMacroErrFlag= GetErrFlagAdr( );

                    char *p;

                   

                    if(Result==X_ OK)

                    {

                      for(p=TestNumCmdStr ; *p; p++)

                        if(*p<'0' || *p>'9')

                          break;

                   

                      *pMacroErrFlag = *p!=’\0’;

                    }

                    else

                      *pMacroErrFlag = TRUE;

                   

                    CmdEnd();

                  }

                   

                   

                  Peter

                   

                  Från: cc2-dev-l@yahoogrou ps.com [mailto:cc2-dev-l@yahoogrou ps.com] För L. Lee Saunders
                  Skickat: den 20 juli 2010 16:56
                  Till: dev
                  Ämne: RE: [cc2-dev-l] How do you write a branch macro command

                   

                   

                  Mike,
                   
                  In walking through your code - in an attempt to understand it - I noticed you are making an API Service call (SVC) to the API command GoToLabel.  Yet in walking through XPSVC.CPY, I cannot find a reference to GoToLabel.  I even did a search of the entire Toolkit and I could not find it.
                   
                  Any help would be appreciated.
                   
                  Thanks,
                  Lee
                    

                  Here is the code that ends the IFERR command, showing taking
                  the branch or not:

                  WasErr: test IfErrFlag,1 ;was an error flagged?
                  jz abort
                  ;
                  doGo: SVC GoToLabel,<offset LblName>
                  abort: SVC CmdEnd

                  Mike

                  On 7/19/2010 12:08 PM, Larry wrote:
                  > Everyone,
                  >
                  > Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.
                  >
                  > Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?
                  >
                  > So, is it as simple as ...
                  >
                  > bool XPCALL Command(int Result, int Result1, int Result2)
                  >
                  > Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?
                  >
                  > Or is it more complicated then that?
                  >
                  > L. Lee Saunders
                  >
                  >
                  >
                  > ------------ --------- --------- ------
                  >
                  > To Post a message, send it to: cc2-dev-l@eGroups. com
                  > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscri be@eGroups. comYahoo! Groups Links
                  >
                  >
                  >
                  >

                   


                  Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.

                   

                   


                  The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. Get busy.




                  Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. See how.
                • Peter Olsson
                  You need to provide the prototype (which I think you have): DWORD * XPCALL GetErrFlagAdr(void); Are you using a .cpp-file? In that case you need to add extern
                  Message 8 of 9 , Jul 21, 2010
                  • 0 Attachment

                    You need to provide the prototype (which I think you have):

                    DWORD * XPCALL GetErrFlagAdr(void);

                    Are you using a .cpp-file? In that case you need to add extern “C” to the prototype:

                    extern “C” DWORD * XPCALL GetErrFlagAdr(void);

                    The only other problem I can think of is if your fcw32.lib that doesn’t export _GetErrFlagAdr@0.

                    You can test that with the dumpbin.exe command line command. (It is included in Visual Studio)

                     

                    dumpbin /exports fcw32.lib

                     

                    Peter

                     

                     

                    Från: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] För L. Lee Saunders
                    Skickat: den 20 juli 2010 22:45
                    Till: dev
                    Ämne: RE: [cc2-dev-l] How do you write a branch macro command

                     

                     

                    Am I missing a reference?
                     
                    unresolved external symbol "unsigned long * __stdcall GetErrFlagAdr(void)"

                    L. Lee Saunders
                     
                    "It was only a partial solution, of course, as solutions usually are, and addressed only one specific problem, as solutions usually do. But, as was often also true, it opened the door—if only a crack—for the multitude of solutions to follow." 
                    1632 - Eric Flint
                     
                    my blog: http://oldschooldotnet.blogspot.com
                    Taking Dot Net "Old School" - Playing with old ideas/concepts using the newest tools!
                     
                     




                     


                    To: cc2-dev-l@yahoogroups.com
                    From: saunderl@...
                    Date: Tue, 20 Jul 2010 14:38:45 -0500
                    Subject: RE: [cc2-dev-l] How do you write a branch macro command

                     

                    Thanks Peter, I was beginning to think this may not be possible.  So, it boils down to:

                     

                    Calling my command first, then if I’ve set an error, the Macro IFERR will see it and jump to the error condition.  Where as if my command passes the input (ie, I do NOT set the error flag) the Macro just continues to run without a jump.

                     

                    So, for this example the best name for the command would be: ERRIFNOTNUM, ERR_IF_NOT_NUM, SETERRIFNOTNUM or SET_ERR_IF_NOT_NUM

                     

                    Any preferences from the Macro programmers out there?  I’m looking for a generic naming convention:

                     

                    So, if I wrote a command that took two lines and compared their angles (Not that I’m going to write such a command – I’m just using it as an example), would the best name be:

                     

                    1-      ERRIFNOTEQANGLE

                    2-      ERR_IF_NOT_EQ_ANGLE

                    3-      SET\ERRIFNOTEQANGLE

                    4-      SET_ERR_IF_NOT_EQ_ANGLE

                     

                    Any Votes, one way or another?

                     

                    Lee

                     

                    From: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] On Behalf Of Peter Olsson
                    Sent: Tuesday, July 20, 2010 12:51 PM
                    To: cc2-dev-l@yahoogroups.com
                    Subject: Re: [cc2-dev-l] How do you write a branch macro command

                     

                     

                    I don’t think GoToLabel is exported. The easiest workaround is to write a TESTNUM command and then use IFERR to do the jump in the macro.

                    (The code below is not tested so will probably contain a few errors, but should give you the general idea.)

                     

                    The macro would be:

                     

                    MACRO CheckInput

                    GL;var;^DUser input:

                    IFERR UserCancel

                    TESTNUM;var

                    IFERR NotANumber

                    GL;comment;Run code for numbers

                    :NotANumber

                    GL;comment;Run code for numbers and non-numbers

                    :UserCancel

                    ENDM

                     

                    The actual XP command would be:

                     

                    DWORD * XPCALL GetErrFlagAdr(void);

                     

                    ////////////////////////////////////////////////////////////////

                     

                    void XPCALL TestNumCmd1(int Result, int Result1, int Result2);

                     

                    static char TestNumCmdStr[128];

                     

                    FORMST(lpszTestNumCmd1, "Text: ")

                     

                    RDATA rTestNumCmd1 = {sizeof(RDATA), RD_TxWord, NULL, RDF_C | RDF_SPACEOK, (DWORD *)TestNumCmdStr,

                    (DWORD *)&lpszTestNumCmd1, RDC_ARROW, TestNumCmd1, NULL, NULL, 0, NULL, 0};

                     

                    void XPCALL TestNumCmd(void)

                    {

                      ReqData(&rTestNumCmd1);

                     

                    void XPCALL TestNumCmd1(int Result, int Result1, int Result2)

                    {

                      DWORD *pMacroErrFlag=GetErrFlagAdr();

                      char *p;

                     

                      if(Result==X_OK)

                      {

                        for(p=TestNumCmdStr; *p; p++)

                          if(*p<'0' || *p>'9')

                            break;

                     

                        *pMacroErrFlag = *p!=’\0’;

                      }

                      else

                        *pMacroErrFlag = TRUE;

                     

                      CmdEnd();

                    }

                     

                     

                    Peter

                     

                    Från: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] För L. Lee Saunders
                    Skickat: den 20 juli 2010 16:56
                    Till: dev
                    Ämne: RE: [cc2-dev-l] How do you write a branch macro command

                     

                     

                    Mike,
                     
                    In walking through your code - in an attempt to understand it - I noticed you are making an API Service call (SVC) to the API command GoToLabel.  Yet in walking through XPSVC.CPY, I cannot find a reference to GoToLabel.  I even did a search of the entire Toolkit and I could not find it.
                     
                    Any help would be appreciated.
                     
                    Thanks,
                    Lee
                      

                    Here is the code that ends the IFERR command, showing taking
                    the branch or not:

                    WasErr: test IfErrFlag,1 ;was an error flagged?
                    jz abort
                    ;
                    doGo: SVC GoToLabel,<offset LblName>
                    abort: SVC CmdEnd

                    Mike

                    On 7/19/2010 12:08 PM, Larry wrote:
                    > Everyone,
                    >
                    > Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.
                    >
                    > Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?
                    >
                    > So, is it as simple as ...
                    >
                    > bool XPCALL Command(int Result, int Result1, int Result2)
                    >
                    > Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?
                    >
                    > Or is it more complicated then that?
                    >
                    > L. Lee Saunders
                    >
                    >
                    >
                    > ------------------------------------
                    >
                    > To Post a message, send it to: cc2-dev-l@...
                    > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...! Groups Links
                    >
                    >
                    >
                    >

                     


                    Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.

                     

                     


                    The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. Get busy.

                     

                     


                    Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. See how.

                  • L. Lee Saunders
                    Extern “C”. I thought about that. I also thought that I may have to write a glue routine so I got sidetracked on that …. So, thanks Peter, I can now
                    Message 9 of 9 , Jul 21, 2010
                    • 0 Attachment

                      Extern “C”.  I thought about that.  I also thought that I may have to write a glue routine so I got sidetracked on that ….

                       

                      So, thanks Peter, I can now get farther in my endeavors.

                       

                      Lee

                       

                      From: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] On Behalf Of Peter Olsson
                      Sent: Wednesday, July 21, 2010 2:22 AM
                      To: cc2-dev-l@yahoogroups.com
                      Subject: Re: [cc2-dev-l] How do you write a branch macro command

                       

                       

                      You need to provide the prototype (which I think you have):

                      DWORD * XPCALL GetErrFlagAdr(void);

                      Are you using a .cpp-file? In that case you need to add extern “C” to the prototype:

                      extern “C” DWORD * XPCALL GetErrFlagAdr(void);

                      The only other problem I can think of is if your fcw32.lib that doesn’t export _GetErrFlagAdr@0.

                      You can test that with the dumpbin.exe command line command. (It is included in Visual Studio)

                       

                      dumpbin /exports fcw32.lib

                       

                      Peter

                       

                       

                      Från: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] För L. Lee Saunders
                      Skickat: den 20 juli 2010 22:45
                      Till: dev
                      Ämne: RE: [cc2-dev-l] How do you write a branch macro command

                       

                       

                      Am I missing a reference?
                       
                      unresolved external symbol "unsigned long * __stdcall GetErrFlagAdr(void)"

                      L. Lee Saunders
                       
                      "It was only a partial solution, of course, as solutions usually are, and addressed only one specific problem, as solutions usually do. But, as was often also true, it opened the door—if only a crack—for the multitude of solutions to follow." 
                      1632 - Eric Flint
                       
                      my blog: http://oldschooldotnet.blogspot.com
                      Taking Dot Net "Old School" - Playing with old ideas/concepts using the newest tools!
                       
                       




                       


                      To: cc2-dev-l@yahoogroups.com
                      From: saunderl@...
                      Date: Tue, 20 Jul 2010 14:38:45 -0500
                      Subject: RE: [cc2-dev-l] How do you write a branch macro command

                       

                      Thanks Peter, I was beginning to think this may not be possible.  So, it boils down to:

                       

                      Calling my command first, then if I’ve set an error, the Macro IFERR will see it and jump to the error condition.  Where as if my command passes the input (ie, I do NOT set the error flag) the Macro just continues to run without a jump.

                       

                      So, for this example the best name for the command would be: ERRIFNOTNUM, ERR_IF_NOT_NUM, SETERRIFNOTNUM or SET_ERR_IF_NOT_NUM

                       

                      Any preferences from the Macro programmers out there?  I’m looking for a generic naming convention:

                       

                      So, if I wrote a command that took two lines and compared their angles (Not that I’m going to write such a command – I’m just using it as an example), would the best name be:

                       

                      1-      ERRIFNOTEQANGLE

                      2-      ERR_IF_NOT_EQ_ANGLE

                      3-      SET\ERRIFNOTEQANGLE

                      4-      SET_ERR_IF_NOT_EQ_ANGLE

                       

                      Any Votes, one way or another?

                       

                      Lee

                       

                      From: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] On Behalf Of Peter Olsson
                      Sent: Tuesday, July 20, 2010 12:51 PM
                      To: cc2-dev-l@yahoogroups.com
                      Subject: Re: [cc2-dev-l] How do you write a branch macro command

                       

                       

                      I don’t think GoToLabel is exported. The easiest workaround is to write a TESTNUM command and then use IFERR to do the jump in the macro.

                      (The code below is not tested so will probably contain a few errors, but should give you the general idea.)

                       

                      The macro would be:

                       

                      MACRO CheckInput

                      GL;var;^DUser input:

                      IFERR UserCancel

                      TESTNUM;var

                      IFERR NotANumber

                      GL;comment;Run code for numbers

                      :NotANumber

                      GL;comment;Run code for numbers and non-numbers

                      :UserCancel

                      ENDM

                       

                      The actual XP command would be:

                       

                      DWORD * XPCALL GetErrFlagAdr(void);

                       

                      ////////////////////////////////////////////////////////////////

                       

                      void XPCALL TestNumCmd1(int Result, int Result1, int Result2);

                       

                      static char TestNumCmdStr[128];

                       

                      FORMST(lpszTestNumCmd1, "Text: ")

                       

                      RDATA rTestNumCmd1 = {sizeof(RDATA), RD_TxWord, NULL, RDF_C | RDF_SPACEOK, (DWORD *)TestNumCmdStr,

                      (DWORD *)&lpszTestNumCmd1, RDC_ARROW, TestNumCmd1, NULL, NULL, 0, NULL, 0};

                       

                      void XPCALL TestNumCmd(void)

                      {

                        ReqData(&rTestNumCmd1);

                       

                      void XPCALL TestNumCmd1(int Result, int Result1, int Result2)

                      {

                        DWORD *pMacroErrFlag=GetErrFlagAdr();

                        char *p;

                       

                        if(Result==X_OK)

                        {

                          for(p=TestNumCmdStr; *p; p++)

                            if(*p<'0' || *p>'9')

                              break;

                       

                          *pMacroErrFlag = *p!=’\0’;

                        }

                        else

                          *pMacroErrFlag = TRUE;

                       

                        CmdEnd();

                      }

                       

                       

                      Peter

                       

                      Från: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] För L. Lee Saunders
                      Skickat: den 20 juli 2010 16:56
                      Till: dev
                      Ämne: RE: [cc2-dev-l] How do you write a branch macro command

                       

                       

                      Mike,
                       
                      In walking through your code - in an attempt to understand it - I noticed you are making an API Service call (SVC) to the API command GoToLabel.  Yet in walking through XPSVC.CPY, I cannot find a reference to GoToLabel.  I even did a search of the entire Toolkit and I could not find it.
                       
                      Any help would be appreciated.
                       
                      Thanks,
                      Lee
                        

                      Here is the code that ends the IFERR command, showing taking
                      the branch or not:

                      WasErr: test IfErrFlag,1 ;was an error flagged?
                      jz abort
                      ;
                      doGo: SVC GoToLabel,<offset LblName>
                      abort: SVC CmdEnd

                      Mike

                      On 7/19/2010 12:08 PM, Larry wrote:
                      > Everyone,
                      >
                      > Say you wanted to write a command that would work in a macro as a branching command - similar to IFDEF or IFERR.
                      >
                      > Say you want a IFNUM where if the string entered IS a NUMBER, then allow it to continue, if not then .... ?
                      >
                      > So, is it as simple as ...
                      >
                      > bool XPCALL Command(int Result, int Result1, int Result2)
                      >
                      > Where Command is the return from the RData call that gets the value we want to look at to see if it is really a number?
                      >
                      > Or is it more complicated then that?
                      >
                      > L. Lee Saunders
                      >
                      >
                      >
                      > ------------------------------------
                      >
                      > To Post a message, send it to: cc2-dev-l@...
                      > To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...! Groups Links
                      >
                      >
                      >
                      >

                       


                      Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. Learn more.

                       

                       


                      The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. Get busy.

                       

                       


                      Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. See how.

                    Your message has been successfully submitted and would be delivered to recipients shortly.