Frequently Asked Questions About Embedded Scripting and Math Expression Parsing
  1. Which operating system does Embedded Ch support?

  2. Can you show me a simple sample to run Embedded Ch code?

  3. How to call a function in a Ch script from the binary application?

  4. How to callback C functions in the binary main program from a Ch script?

  5. Is Ch a bytecode interpreter? Can I generate bytecode for Embedded Ch?

  6. How to direct Ch 2D/3D graphical output into a specific window in Embedded Ch?

  7. I am interested in parsing and evaluating math expressions with Embedded Ch. I don't need a fully embedded scripting language. Can it be done easily with Embedded Ch?

  8. It appears that Ch provides a makefile-based build system that uses special commands such as dlcomp and dllink, which is helpful for cross-platform development. Can we use Visual Studio's project based system or alternate systems such as qmake (Qt's make system)?

  9. How to replace dllink in my Unix GUI compilation?

  10. What compilers does Embedded Ch support? Do you support Borland or MingW compiler?

  11. I got the compiler error in Windows MFC application, how to resolve it?

  12. Does Embedded Ch support multi-threading?

  13. How to abort an embedded Ch thread?

  14. Does Embedded Ch support debugging?

  15. Does Embedded Ch have memory leak?

  16. Can Embedded Ch be used in real time OS?

  17. Can I parse Ch scripts to check if there are syntax errors before I execute them?

  18. How can I redirect the stdout or stderr stream from Embedded Ch to a file?

  19. How to suppress the invalid function error messaged generated by Ch_CallFuncByName() at runtime?

  20. I use Embedded Ch and have a C program that launches Ch scripts in Windows. This C code calls function popen() to capture the output and displays it through GUI. I see the output of the C program, but not the output from Ch scripts. How to display the output from the stdout stream from both C and Ch scripts?

  21. Can I run Ch script in either memory or from a file?

  22. How can I run Ch function from memory, pass arguments, and return a value?

  23. How can I call ch function that is changed during the second call without restarting embedded ch engine?

  24. Global variables defined in Ch script file become NULL when they are accessed from the binary C space, how to fix it?

  25. Does Ch support C++ class inheritance? Can Embedded Ch interface with C++ class with inheritance?

  26. Does Ch support some kind of reflection mechanism that will enable it to look up class methods (i.e: all the information exists in the chf file)? How to use reflection mechanism to get e class or struct name?

  27. I have many functions in a C library. Is there a convenient way to expose these functions to Ch scripts without manually writing wrapper function files with file extension .chf?

  28. I don't want my end users to install a standalone Ch separately. How can I distribute my application with Embedded Ch? How can I distribute wrapper function files with file extension .chf? How can I distribute minimized run time environment with features of C/C++ only?

  29. How to specify a user-defined paths to the Ch files and DLL?

  30. How does Embedded Ch change the PATH after calling Ch_Initialize()?

  31. Is it royalty free to distribute a Ch run-time environment?

  32. We use NI LabVIEW, do you have a demo using Embedded Ch with LabView? Do you have other demo examples using Embedded Ch?

  33. Where can I find more information about Embedded Ch?

  34. Can I have Embedded Ch user's references about using Embedded Ch?

  35. How to disable floating point exception handling under Borland C/C++ compiler or CBuilder?

  36. When I run an application with Embedded Ch, I get the message: "Error: The contents of the license file are invalid."

  37. I would like to use Embedded Ch, what is the price?

Q: Which operating system does Embedded Ch support?

Embedded Ch runs where Ch is available. It supports Windows, Linux, Mac OS X, Solaris, HP-UX, FreeBSd and QNX.

Q: Can you show me a simple sample to run Embedded Ch code?

Below is a sample C code embedch1.c to run Ch script embedch1.ch. The program embedch1.c needs to be compiled and linked with the Embedded Ch library to call the APIs Ch_Initialize(), Ch_RunScrip(), and Ch_End() in the library.

/* Filename: embedch1.c */ #include <embedch.h> #include <stdio.h> int main() { ChInterp_t interp; char *argvv[]={"embedch1.ch", NULL}; /* initialize embedded Ch */ Ch_Initialize(&interp, NULL); /* run an embedded Ch program (embedch1.ch) indicated by argvv */ Ch_RunScript(interp, argvv); /* release memory and terminate the shell */ Ch_End(interp); return 0; } ------------------------------------------------------------------------ /* Flename: embedch1.ch */ #include <stdio.h> int main () { printf ("hello world \n"); return 0; } You can download the source code for this example and two examples described below here.

Q: How to call a function in a Ch script from the binary application?

There are many different ways to functions in a Ch script. Below is a sample C code embedch2.c in which API Ch_CallFuncByName() calls function func() in the Ch script embedch2.ch. The arguments x, N, and a are passed from the binary space to the script space.

/* Filename: embedch2.c */ #include <embedch.h> #include <stdio.h> #define N 5 int main() { ChInterp_t interp; char *argvv[]={"embedch2.ch", NULL}; int retval; double x =10; int a[N] = {1, 2, 3, 4, 5}; /* passed this array to the Ch space */ /* initialize embedded Ch */ Ch_Initialize(&interp, NULL); /* run an embedded Ch program (embedch1.ch) indicated by argvv */ Ch_RunScript(interp, argvv); /* call Ch function func(); pass arguments x, N, and a; get the returned value in retval */ Ch_CallFuncByName(interp, "func", &retval, x, N, a); /* release memory and terminate the shell */ Ch_End(interp); return 0; } ------------------------------------------------------------------------ /* Flename: embedch2.ch */ #include <stdio.h> int func(double x, int n, int *a) { int i; printf("x = %f\n", x); for(i=0; i<n; i++) printf("a[%d] = %d\n", i, a[i]); a[0] = 100; /* change element a[0] in the C space */ return 0; } int main () { printf ("hello world \n"); return 0; } Q: How to callback C functions in the binary main program from a Ch script?

Please read chapter 5 section "Calling Back C Functions in the Main Program from Ch Space" in Embedded Ch User's Guide located at CHHOME/docs/embedch.pdf.
We provide many examples for different situations for handling callback C functions in the main program from Ch scripts. It includes an example to pass a function from C to Ch, and then pass it back from Ch to C, and callback in C.

Below is a sample C code embedch3.c with a C function func() called from a Ch script embedch3.ch. The API Ch_DelcareFunc() makes the function func() available in the script space. The arguments from the script space are passed to the interface function func_chdl() first in the binary space, which in turn calls the binary function func(). The interface function func_chdl() can be automatically generated using the utilities provided in the Embedded Ch SDK.

/* Filename: embedch3.c */ #include <embedch.h> #include <stdio.h> /* original C function */ int func(double x, int n, int *a) { int i; printf("x = %f\n", x); for(i=0; i<n; i++) printf("a[%d] = %d\n", i, a[i]); a[0] = 100; /* change element a[0] in the Ch space */ return 0; } /* interface to func() */ EXPORTCH int func_chdl(void *varg) { ChInterp_t interp; ChVaList_t ap; double x; int n, *a; int retval; Ch_VaStart(interp, ap, varg); x = Ch_VaArg(interp, ap, double); n = Ch_VaArg(interp, ap, int); a = Ch_VaArg(interp, ap, int *); retval = func(x, n, a); Ch_VaEnd(interp, ap); return retval; } int main() { ChInterp_t interp; char *argvv[]={"embedch3.ch", NULL}; /* initialize embedded Ch */ Ch_Initialize(&interp, NULL); /* declare function func() in the Ch space */ Ch_DeclareFunc(interp, "int func(double x, int n, int *a);", func_chdl); /* run an embedded Ch program (embedch3.ch) indicated by argvv */ Ch_RunScript(interp, argvv); /* release memory and terminate the shell */ Ch_End(interp); return 0; } ------------------------------------------------------------------------ /* Flename: embedch3.ch */ #include <stdio.h> #define N 5 int main (){ double d =10; int a[N] = {1, 2, 3, 4, 5}; /* passed this array to the C space */ int retval; retval = func(d, N, a); /* call func() in the C space */ func(d, N, a); /* call func() in the C space */ return 0; }

Q: Is Ch a bytecode interpreter? Can I generate bytecode for Embedded Ch?

Ch is not a bytecode interpreter. It parses C/Ch/C++ scripts and generates symbol tables in memory, then runs the code from the memory directly. All information in scripts are available in the hosting application.

The advantage for using Ch scripts is that Ch script is usually smaller than its corresponding bytecode, it can save bandwidth for you significantly.

Q: How to direct Ch 2D/3D graphical output into a specific window in Embedded Ch?

For 2D/3D graphical plottings, you need to have Ch Professional and Embedded Ch Professional instead of Ch Standard and Embedded Ch Standard.

You can save a graphical output in a file first, then display the plot in a specific existing window. We have an example below to show you how it can be done.

http://www.softintegration.com/products/sdk/embedch/plotexample/

Q: I am interested in parsing and evaluating math expressions with Embedded Ch. I don't need a fully embedded scripting language. Can it be done easily with Embedded Ch?

Yes. It can be easily done. If you only use expressions, your functions, and built-in mathematical functions listed in the header file math.h in Embedded Ch, you don't need to distribute Ch run time files. Some API functions are listed below:

Ch_ExprParse(), Ch_ExprEval(), Ch_ExprCalc(), Ch_AppendRunScript(), Ch_SetVar()

Below is a sample code that demonstrate how this can be done.

/* File Name: mathparse.c */ #include <stdio.h> #include <embedch.h> int main() { double retval, c_x, total = 0; char inputStr[100]; /* power(x,2) means x^2 in math */ printf("Enter your math expression such as: pow(x,2)+2*sin(x)+3\n"); fgets(inputStr, 99, stdin); inputStr[strlen(inputStr)-1] = '\0'; /* initialize Embedded Ch */ Ch_Initialize(NULL,NULL); /* declare variables x in Ch space */ Ch_AppendRunScript(NULL,"double x;"); /* add your functions in Ch space */ /* Ch_AppendRunScript(NULL, "double func(double x) {double retval; retval = 2*x; return retval;}"); */ for(c_x = 1; c_x <= 1000; c_x++) { /* assign c_x in C space to x in Ch space */ Ch_SetVar(NULL, "x", CH_DOUBLETYPE, c_x); /* calculate the math expression in Ch space and get the return value in "retval" if you don't want to get the result of Ch expressions, you can use Ch_ExprEval() */ Ch_ExprCalc(NULL, inputStr, CH_DOUBLETYPE, &retval); total += retval; } printf("The total value is: %f\n", total); Ch_End(NULL); return 0; }

Winplot is an example of how Embedded Ch is used to calculate mathematical expressions entered by the user through a graphical user interface in Windows. The mathematical expression is then plotted.

Q: It appears that Ch provides a makefile-based build system that uses special commands such as dlcomp and dllink, which is helpful for cross-platform development. Can we use Visual Studio's project based system or alternate systems such as qmake (Qt's make system)?

We provide commands dlcomp and dllink which can be used in Makefile so that you can use the same makefile for building applications with Embedded Ch across different platforms with different C/C++ compilers. You can also build applications with Embedded Ch using your preferred IDE.

Please check section "Executables in Windows Using Visual .NET" and section "Building Executables in Windows Using Visual C++ 6.0" in Chapter 1 in Embedded Ch SDK User's Guide at CHHOME/docs/embedch.pdf. It describes what header files and libraries you need to add for the project. You can apply the same header files and libraries for any other alternate systems like qmake.

You can also find samples for using both VC++ 6.0 and VC.NET projects for Embedded Ch. The sample project files embedfuncmain.dsw and embedfuncmain.vcproj for interface C functions can be found in the directory CHHOME/demos/embedch/ref/embedfuncmain. The sample project files embedclassmain.dsw and embedclassmain.vcproj for interface C++ classes are located in directory CHHOME/demos/embedch/ref/embedclassmain.

Q: How to replace dllink in my Unix GUI compilation?

You can take a look at the file below as a reference.

/usr/local/ch/demos/embedch/chapters/chapter1/Makefile

Q: What compilers does Embedded Ch support? Does it support Borland or MingW compiler?

Both Borland and MingW compilers are supported. The tested and workable compilers for Embedded Ch SDK are as follows.

  • Microsoft Visual Studio VC++ 6.0, Microsoft Visual Studio .NET 2003 (VC++ 7.0) or above. Borland C/C++ compiler 5.5 and C++ 2005 in window or above. MingW C/C++ compiler (gcc).
  • gcc and g++ in Linux
  • cc and CC from Sun Microsystem in Solaris
  • cc and CC from Hewlet-Packard in HP-UX
  • gcc and g++ in Mac OS X
  • gcc and g++ in FreeBSD
  • qcc, QCC in QNX
We also have examples on how to use Borland and MingW compiler. These examples can be found in the directory CHHOME/demos/SDK/Borland for Ch SDK and CHHOME/demos/embedch/Borland/ for Embedded Ch. MingW examples can be found at CHHOME/demos/SDK/MingW and CHHOME/demos/embedch/MingW. You can find more information on how to use Borland compiler in section "Building Executables in Windows Using Borland C++ Compiler" in Chapter 1 of Embedded Ch SDK User's Guide.

Q: I got the compiler error in Windows MFC application, how to resolve it?

When linking an application against Microsoft Foundation Class (MFC), you might get the following error message.

nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv 
nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc 
nafxcw.lib(olelink.obj) : error LNK2001: unresolved external symbol __mbctype 
Compile your C or C++ program files with option /MD since Embedded Ch is compiled with option /MD so that the same version of library will be used. You also need to specify that you are using MFC in a shared dll. This can be specified in the project settings.

Q: Does Embedded Ch support multi-threading?

Yes. It allows multi Ch interpreter running simultaneously. In our demos, we have samples using POSIX pthread and Windows thread.

Q:How to abort an embedded Ch thread?

Embedded Ch provides API Ch_Abort(), which can be called to abort a running Ch thread. It can be also called to abort the execution of a Ch script in a different thread.
Please check detailed examples in Appendix "APIs for Embeddedch" for function Ch_Abort() in Embedded Ch User's Guide.

Q: Does Embedded Ch support debugging?

Yes. Embedded Ch has extensive support for callback and debug functions. Chapter 7 in Embedded Ch User's guide contains a detailed example with source code for using debugging API in Embedded Ch. ChIDE is another sample program that uses Embedded Ch for debugging.

Q: Does Embedded Ch have memory leak?

We have gone through extensive testing and there is no memory leak in Embedded Ch.

Q: Can Embedded Ch be used in real time OS?

Yes. Embedded Ch has no unexpected garbage collection behind and all behavior is deterministic.

Q: Can I parse Ch scripts to check if there are syntax errors before I execute them?

Yes. Embedded Ch provides solutions to handle complicate cases. For example, it can parse a script in the memory as well as loading and parsing a script from a file. Please Please check functions Ch_ParseScript(), Ch_ExprParse() and Ch_AppendParseScript about parsing scripts.

Q: How can I redirect the stdout or stderr stream from Embedded Ch to a file?

You can use Embedded Ch API Ch_Reopen() to redirect the output stream for stdout and stderr from Ch into a file that can be used as a log file or opened via your C application. More details can be found at in section 1.6 "Redirecting Standard Output and Error Stream from Embedded Ch" in Embedded Ch User' Guide.

Q: How to suppress the invalid function error messaged generated by Ch_CallFuncByName() at runtime?

You can check if a function is defined in the Ch space by using Ch_SymbolAddByName() before Ch_CallFuncByName() is called.

Q:I use Embedded Ch and have a C program that launches Ch scripts in Windows. This C code calls function popen() to capture the output and displays it through GUI. I see the output of the C program, but not the output from Ch scripts. How to display the output from the stdout stream from both C and Ch scripts?

You can put setbuf(stdout, NULL) in all Ch scripts or in a header file for Ch scripts. All of the output from Ch scripts will be unbuffered and displayed in a correct sequence.

Q: Can I run Ch script in either memory or from a file?

Yes. You can use Ch_AppendRunScript() to execute Ch code in memory and use Ch_RunScript() or Ch_AppendRunScriptFile() to execute Ch code in a file.

Q: How can I run Ch function from memory and get the returned value?

The following is an example about how to call Ch function, pass arguments, and return a value. The Ch function runs a loop with 10000 iterations.

#include <embedch.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #define N1 10000 #define N2 100 int main() { ChInterp_t interp; int retval; char string[500]; double x[N1]; double output[N1]; /* define function to run in Ch space */ sprintf(string, "int func(int n1, int n2, double *x, double *output) { \ int i; \ for (i = 0; i<n1;i++){ \ if(i>n2){ \ output[i] = pow(x[i],2)*sin(3.14/2*x[i]); \ } \ else { \ output[i] = x[i]/2; \ } \ } \ return 0;}"); x[0] = 1; x[1] = 2; x[2] = 3; /* initialize embedded Ch */ Ch_Initialize(&interp, NULL); /* load Ch function */ Ch_AppendRunScript(interp, string); /* call Ch function, and get the returned value in retval and output */ Ch_CallFuncByName(interp, "func", &retval, N1, N2, x, output); Ch_End(interp); printf("output[0] = %f\n", output[0]); printf("output[1] = %f\n", output[1]); return 0; } /* output : output[0] = 0.500000 output[1] = 1.000000 */

Q: How can I call ch function that is changed during the second call without restarting embedded ch engine?

You may check the link below about how to unload a function or variable.

The function Ch_DeclareVar() in Appendix A of Embedded Ch User's guide has the example about how it can be done.

Q: global variables defined in Ch script file become NULL when they are accessed from the binary C space, how to fix it?

When you load your Ch script from C space, you used Ch_ParseScript() function, the initialization of global variables in Ch space are not performed when Ch_ParseScript() is executed. You can change Ch_ParseScript() to Ch_RunScript().

However, if you still want to use Ch_ParseScript() and access the global variables in the Ch space, you need to call Ch_InitGlobalVar() first.

Q: Does Ch support C++ class inheritance? Can Embedded Ch interface with C++ class with inheritance?

Ch itself doesn't support inheritance. However, Ch can interafce with inherited class in C++ space. For example, you have the C++ code below:

class base { public: int get_base_i(); void set_base_i(int i); virtual void mybase(); private: int base_i; } class super:base{ public: int super(); virtual void mybase(); } In Ch, you can create a Ch class called super listed below to export C++ class super. Then you can access all binary member functions in C++ super class from Ch class. class super{ public: int super(); int get_base_i(); void set_base_i(int i); void mybase(); }

Q:Does Ch support some kind of reflection mechanism that will enable it to look up class methods (i.e: all the information exists in the chf file)? How to use reflection mechanism to get e class or struct name?

Yes. The following APIs can be used.

extern int Ch_SymbolTotalNum(ChInterp_t interp) extern int Ch_SymbolNum(ChInterp_t interp, const char *name) extern void *Ch_SymbolAddr(ChInterp_t interp, int num) extern char *Ch_SymbolName(ChInterp_t interp, int num) extern int Ch_UserDefinedSize(ChInterp_t interp, const char *name) extern char *Ch_UserDefinedName(ChInterp_t interp, const char *name) extern void *Ch_UserDefinedAddr(ChInterp_t interp, const char *name) extern int Ch_DataType(ChInterp_t interp, const char *name) To get a class or struct name, you can use the following three functions. extern void *Ch_UserDefinedAddr(ChInterp_t interp, const char *name); extern char *Ch_UserDefinedName(ChInterp_t interp, const char *name); extern int Ch_UserDefinedSize(ChInterp_t interp, const char *name); Ch provides the chf file auto generator (c2chf) for C functions. To generate the wrapper functions for C++ class, you can treat the class member funtions as C functions to generate the wrapper chf files and then make the modifications.

Q: I have many functions in a C library. Is there a convenient way to expose these functions to Ch scripts without manually writing wrapper function files with file extension .chf?

Yes. Ch SDK has an utility called c2chf, you can use it to generate wrappers automatically. You can find more information about c2chf in chapter 3 in Ch SDK User's Guide at CHHOME/docs/chsdk.pdf.

Q: I don't want my end users to install a standalone Ch separately. How can I distribute my application with Embedded Ch? How can I distribute wrapper function files with file extension .chf? How can I distribute minimized run time environment with features of C/C++ only?

We offer run time license for the distrubtion so that the end user doesn't need to worry about the license issue.

Your end users do not have to install standalone Ch in order to use your application with Embedded Ch.

After obtaining the authorization, you need to distribute files located in the directory CHHOME/toolkit/embedch with your applications. This directory contains the Ch runtime environment. Typically, it will be placed under the home directory of your application. Your application program should set the Embedded Ch home directory properly in option.chhome argument before calling Ch_Initialize().

If you want to distribute minimized run time environment with features of C/C++ only, you may only need to distribute the following files from CHHOME/toolkit/embedch. It will reduce the size of run time environment significantly.

CHHOME/toolkit/embedch/config/chrc CHHOME/toolkit/embedch/include/*.h used header files CHHOME/toolkit/embedch/lib/libc/*.chf used functions CHHOME/toolkit/embedch/dl/*.dl used .dl for header files. CHHOME/toolkit/embedch/extern/lib/*.dl used for Embedded Ch Below is a sample code for building distribution. /* We assume that your application is distributed in /usr/local/companyname in Unix or C:/myApplication in Windows. The Embedded Ch runtime environment should be copied from CHHOME/toolkit/embedch in your development machine and distributed at /usr/local/companyname/embedch in Unix and C:/myApplication/embedch in Windows in a target machine. Then Embedded Ch home directory will be /usr/local/companyname/embedch in Unix and C:/myApplication/embedch in Windows. */ #include <embedch.h> #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { int len; ChInterp_t interp; ChOptions_t option; char *proghome, *p; /* get the home dir for your application program from an environment variable or registry value PROG_HOME which was setup during the installation of your application in a target machine. The Embedded Ch home directory will be PROG_HOME/embedch which needs be setup using option.chhome as follows. */ /* set option.shelltype */ option.shelltype = CH_REGULARCH; /* set option.chhome */ proghome = getenv("PROG_HOME"); /* from an environment variable */ /* or obtain the value for proghome from a registry value in Windows, using Windows API RegOpenKeyEx() and RegQueryValueEx(). */ len = strlen(proghome)+ strlen("/embedch")+1; option.chhome = (char *)malloc(len); strcpy(option.chhome, proghome); strcat(option.chhome, "/embedch"); option.chmtdir= NULL; /* use default chmt dir */ Ch_Initialize(&interp, &option); /* ... */ Ch_End(interp); free(option.chhome); return 0; }

If you have function files (.chf) used to interface with binary functions, you need to distribute them along with your application. You may put these function files in a separate directory under your application home directory such as C:/MyApplication/chffile. Then add the directory in the system variable _fpath in file config/chrc under the home directory of Embedded Ch. The file CHHOME/toolkit/embedch/config/chrc contains an example on how to add a directory.

However, if you use Embedded Ch for parsing and processing math and expressions, you may not need to distribute Embedded Ch runtime environment, namely Embedded Ch Standard or Professional Edition.

You can find more detailed information about distribution of your applications with Embedded Ch in section "Distributing Embedded Ch in Your Applications" of the first chapter in Embedded Ch User's Guide. It includes the details information about how to add DLL path in the embedded ch run time.

Click here for using NI LabVIEW with Embedded Ch.

ChExcel is a sample distribution of an application with Embedded Ch, but without a standalone Ch.

Q: How to specify a user-defined paths to the Ch files and DLL?

You can specify the paths _path, _lpath, _ipath etc in the file in either the system startup file EMBEDDED_CHHOME/config/chrc or individual user's startup ~/_chrc. More about _path, _lpath and _ipath can be found in Ch User's Guide (chguide.pdf). You can look over the index in the Ch User's Guide.

For, the command search paths can be modified in a startup file as follows:

_path = stradd(_path, stradd(getenv("HOME"),"/bin;"));

Q: How does Embedded Ch change the PATH after calling Ch_Initialize()?

In Ch and Embedded Ch, the value of the environmental variable "PATH" is the same as that of the system variable "_path" in Ch. When the API Ch_Initialize() in Embedded Ch is called, it will change the value of the system environment variable PATH. For windows, the default setting is:

EMBED_CHHOME\bin;EMBED_CHHOME\bin;EMBED_CHHOME\toolkit\bin;EMBED_CHHOME\toolkit\sbin;WINDIR;WINDIR\system32 However, you can modify the value of the environment variable PATH by changing the value of _path in Ch in the system startup file EMBED_CHHOME/config/chrc or in the individual startup file _chrc in Windows and .chrc in Unix in the user's home directory.

For example, to add C:/my_application/dll_directory, to the value for PATH, use

_path = stradd(_path, "C:/my_application/dll_directory;");

If you want to restore the PATH after calling Ch_Initialize(), you may obtain the value for PATH using getenv() to save it in a string, call Ch_Initialize(), then, call putenv() to restore the original value for PATH.

Q:Is it royalty free to distribute a Ch run-time environment?

It depends. Please click here for more details.

Q: We use NI LabVIEW, do you have a demo using Embedded Ch with LabView? Do you have other demo examples using Embedded Ch?

You may find a link in the NI website for using Embedded Ch with LabVIEW. However, you can click here to find the latest example for using LabVIEW with Embedded Ch. You can download the latest demo source code here.

Also, You can download and try ChExcel. ChExcel is freeware and it is a Microsoft Excel add-in. It allows Excel speadsheets to be manipulated through C/C++ scripts.

Q: Where can I find more information about Embedded Ch?

You can find the following two links helpful. Embedded Solution and Embedded Ch product. To use Embedded Ch, you need to install Ch Standard or Ch Professional, and Embedded Ch SDK. Then you can find Embedded Ch SDK User's Guide at CHHOME/docs/embedch.pdf.

Q: Can I have Embedded Ch user's references about using Embedded Ch?

Sure. Below are comments from some users of Embedded Ch.

  • Errol Korpinen, manager at Skyworks Solutions, Inc, said:

    "Ch and Embedded Ch toolkit provide a framework and development environment that enabled the development of an extremely flexible Automatic Test Equipment (ATE) environment. The standard ANSI C/C++ support makes training an issue of the past.

    The performance of the Ch interpreter far exceeded our expectations. The technical support from SoftIntegration was exceptional and sets a standard for other developers to achieve.

    I strongly recommend Embedded Ch for all people developing Script based Test Environments."

  • Michael Jang, CEO of FunctionBay, Inc. said:

    "We provide the state-of-the-art multi-body dynamics (MBD) technology in the RecurDyn family of software. However, our technology is not limited to the traditional MBD area. We are expanding to a complete multi-physics solution that includes finite element analysis, control, computational fluid dynamics, and optimization. Our customers include many leading companies.

    Embedded Ch was easily integrated into our products. We are very satisfied with the performance of Embedded Ch for our large-scale complete CAE solutions.

    The interface by which our customers communicate with RecurDyn and input their own functions is critical for effective use of our integrated design and simulation environment for multi-physics systems. Embedded Ch is an ideal solution for modeling and interface with the underlying RecurDyn solver. With Embedded Ch, our customers can not only model and interface with the underlying RecurDyn solver using C/C++ scripts, but also build modeling blocks in C/C++ scripts."

    Embedded Ch saves us the cost for developing and maintaining a proprietary scripting language, and reduces the time for developing our products. We will launch the entire RecurDyn family of software integrated with Embedded Ch soon."

  • Toshiyuki Tega, manager of Technology Group, Axell Corporation, said:

    "Embedded Ch saves us a lot of hard work from implementing our own proprietary scripting language, and makes it possible to provide a robust scripting interface to manipulate our product from outside.

    C scripting is also best suited for our customers, who are heavy C developers themselves. We are very satisfied with embedding Ch into our products."

  • Hua Jin, president of Powersim Inc. said:

    "We greatly appreciate the power and flexibility of a C interpreter bring to the simulation and design of power electronics and motor drive systems. An embedded C interpreter makes it extremely easy to write C code in PSIM without the need of a separate C compiler. The response from our customers on the C Script Block in PSIM, powered by the Embedded Ch interpreter, is very good. Thank you for a well-developed product."

  • Roberto Fichera from Tekno-Soft, Inc said:

    "I use Embedded Ch for multi-threading applications. The result was really great, especial about global user data stuff. I can fetch my per-engine data from the Ch function wrappers. The extensions are coded in a clean way and I don't have to declare global data. This is really great whenever they had to work in multi-threaded application, no strange things to maintain the globals over multiple library loads."

  • Simon Garrison --- CEO, Numerical Innovations LLC said:

    "I was pleasantly surprised to find out how simple Embedded Ch was to implement inside our software products Visual Chip and Fab It! 2008. Embedded Ch is well documented and within a few hours we were able to create our own custom API's, compared to Python which took us weeks. I would recommend Embedded Ch to anyone looking to embed a C scripting language into their software product."

  • Dr. Ho, Peng Yip, The Boeing Company, said:

    "I must say I like Embedded Ch. I accomplished my goal in less than half an hour with Embedded Ch; while I spent a week evaluating Python and tried to get it to do the same, without success.

    Also, I found Python difficult to use, due to different data types. The same is true for all scripting languages that do not support the same C native data types. It is both expensive and inconvenient to convert the entire array into a Python list. It requires to add a callback function to a C++ class, which converts an entire array into a Python Object and pass back to the Python script. So I came with a lot of call-back 'baggage' that clouded my mind.

    Embedded Ch makes my task simpler and easier, with a very clean solution. No need for callback, no separate dll; simply pass the pointer as arguments to the scripted function. No other embedded interpreter has this capability.

    I would highly recommend Ch for embedded scripting, especially those coming from another scripting language. "

  • Paul Thompson, Systems Engineering Manager from TeleCommunication Systems said:

    "TCS is committed to helping wireless carriers meet their obligations for wireless E9-1-1 and meet accessibility guidelines under Section 255 of the Telecommunications Act. Embedded Ch is an ideal solution to customize our products for different customers with different requirements. We have customer specific data that is sent to customers attached to our product.

    With Embedded Ch, our down-stream deployment team is able to add C/C++ scripts to perform string manipulation and output based on customers. This allows our deployment teams to very conveniently customize customer specific data,"

  • Raymond Castonguay, ESDI President and CTO said:

    "Our mission is to provide our customers with the best interferometric solutions. Scripting allows our customers to create their own solutions and customizations, based on the core functionality of the system. Embedded Ch is an excellent scripting engine in C/C++. It adds many new scripting features and functions to IntelliWave including advanced automation, data processing, and systems integration with other programs. It extends our customer's ability to conveniently automate IntelliWave for a variety of tasks in different industries. We believe we will significantly reduce the development, maintenance, and training cost when our developers and users use the same language for our interferometric analysis software."

  • Duncan Mcdonald, Solid Motion Inc. said:

    "I used Ch to prototype part of some complicated embedded code I was having problems with. Ch allowed me to build a test bench to try and duplicate the problem I was having with the embedded code. The embedded code runs on a micro controller and uses a development environment that has limited ability to set break points, observe variables, and other debugging functions. It took me about a day to learn the Ch environment and debugger. I was then able to duplicate my problem, find the root cause, and find a fix. I moved the fix over to the embedded code and it worked! Ch will now be a part of my embedded code development tool set."

  • Ben Midgley said:

    "I work primarily with embedded software. When I need to make some changes that do not relate directly to the hardware and timing is not an issue, I like to essentially module test the code I am working on and I can make changes and get quick feedback using the scripting environment rather than making iterative changes on target which means re-flashing using JTAG and then using a (usually) limited debugger. Ch allows me to work more quickly by copying out the code I am focusing on into a little script where I can wrap it up in a brute force test and more quickly edit and re-test than I can on the real target, especially when refining algorithms which could take hours to iterate on a real platform or test the code that would not normally execute on target (defensive statements). Module test is a good way to develop some things in code. Ch is a great way to module test because no compilation/flashing means more rapid rework/retest cycle.
    Ch is a nice product I found by accident years and years ago and now I am working on code again I have come back to it. I would suggest some promotion though because I am the only person I know that uses Ch.
    As a comment, if I am ever in the position of being the person who sets up the tools for a project I will come looking because I really like this product."

Q: How to disable floating point exception handling under Borland C/C++ compiler or CBuilder?

Borland environment builds applications and DLL with floating point exceptions enabled, while Microsoft does the opposite. In order to work arround the issue it is possible to disable FP exception as shown below.

#include <math.h> #include <float.h> ... // get current floating point status int tmp1 = _control87 (0, 0); // disable floating point exceptions _control87(MCW_EM, MCW_EM); .... // perform script execution // Ch_RunScript(interp, argvv); .... // restore floating point default setting (if you want) _control87 (tmp1, 0xFFFF);

Q: When I run an application with Embedded Ch, I get the message: "Error: The contents of the license file are invalid."

You may need to uninstall the old or expired edition of Embedded Ch in your local machine first, then run the application.

Q: I would like to use Embedded Ch, what is the price?

Please click here for more details.