Home Forums HTBasic Forum How to run the COM mixed Basic/C examples in the IDE?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #9225
    Bradley Rogers
    Participant

      In the HT BasicHELP pdf page 619/3350 topic

      The following examples show how to access a COM area or individual COM variables from within a CSUB.
      This example shows how to access a COM area from a C subprogram.
      10  COM /Test/ B, INTEGER I(9), A$[100]
      20  MAT I=(10)
      30  CALL Tcom1
      40  PRINT I(0)
      50  END
      60  SUB Tcom1
      70   COM /Test/B,INTEGER I(*),A$
      80   I(0)=I(2)*56
      90  SUBEND
      Prototype
      1  COM /Test/ B,INTEGER I(9),A$[100]
      2  END
      10  SUB Tcom1
      20    COM /Test/ B,INTEGER I(*),A$
      30  SUBEND
      C Program
      #include "csub.h"
      struct test             /* COM /Test/ data area def */
      {
      T_FLT  b;             /* REAL B */
      T_INT  i[10];         /* INTEGER I(0:9) */
      T_SUBS l;             /* A$[100] current length */
      U_CHAR a[100];        /* A$ string data */
      };
      tcom1( npar )/* ACCESS FULL COM DATA AREA */
      int npar;             /* number of parameters */
      {
      T_INT c;              /* working variable */
      struct test *t;       /* COM data area pointer */
      t = com_var("Test", 0, 0); /* get COM /Test/ data ptr */
      if( !t )              /* area found? */
       return( 47 );       /* no, area not found */
      c = t->i[2];          /* yes, get 3rd INTEGER element */
      t->i[0] = c * 56;     /* set value of first element */
      return( 0 );          /* no error */
      }
      

      I tried putting the C code in the IDE on the edit screen, and it marks it RED/error

      Had not used this COM much and wanted to find running code examples and understand it better? If anyone can shine light on this? Would this mixed c/basic work within the Win10 OS space? Thanks!

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Scroll to Top
    HTB icon

    Please Sign In