Frequently Asked Questions on Windows
  1. How to resolve "Parameter format not correct" error?
  2. How to reslove "Out of environment space" error for commands in Ch for Windows 95/98/Me?
  3. How to run Windows command in Ch shell without being blocked?
  4. How to write programs for serial port processing?
  5. How to call functions in a Windows DLL library from Ch?
  6. How to catch any keys in Windows?
  7. How to generate plotting using a static SIGL library?
  8. How to zoom back to the original plotting in Ch Pro or SIGL after zooming out?

Q: How to resolve "Parameter format not correct" error?

It happens when you try to run MS-DOS command in Unix syntax. For example,


Q: How to resolve "Parameter format not correct" error?

It happens when you try to run MS-DOS command in Unix syntax. For example,

    C:/> dir /temp/*exe
         Parameter format not correct - "emp".
    C:/>
One can run the command using
C:/> dir \temp\*.exe
The similar error you might get is "The syntax of the command is incorrect" or "Invalid switch - /temp", When you run the command
C:/> type /Ch/bin/dirs.ch
You can fix it by running:
C:/> type \Ch\bin\dirs.ch

Q: How to reslove "Out of environment space" error for commands in Ch for Windows 95/98/Me?

  • Go to your boot drive ( by default, it is C:\ for your machine)
  • editing the c:\config.sys file.
    For Windows 95, right click on "Config.sys" from your explorer or in "My Computer", then select "Edit" from pop up menu.
    For Windows 98/Me, click "Start"=>"Programs"=>"Accessories"=>"System tools"=>"System information"=>"tools" => "System Configuration" and use "Config.sys" Tab to edit config.sys file.
    If the file attribute for config.sys is "Hidden" or "Read-only", change it to "Archive", you can change it back after editing.
  • Check if you can find the line like this in config.sys:
    SHELL=C:\Windows\command.com c:\windows /E:nnnn /P

    if you find the line like above, increase the size for "nnnn" till you don't have "Out of environment space" error. Typically, you can increase 256 bytes every time. If you don't find a line as above, you can add a line like this:
    SHELL=C:\Windows\command.com c:\windows /E:1024 /P

    make sure c:\windows\command.com exists.
  • save config.sys and reboot your computer.
  • In most cases, the above will work. But if the problem still exists, increase your size from 1024 to 2048, and make the line like the following in your config.sys file, and reboot your computer again.
    SHELL=C:\Windows\command.com c:\windows /E:2048 /P

Q: How to run Windows command in Ch shell without being blocked?

Like in Unix, a command in Windows can be executed in the background by appending "&" at the end of the command. For example,

         c:/> notepad &

Q:How to write programs for serial port processing?

Ch supports all Windows serial port I/0 functions listed in CHHOME/include/windows/conio.h, you can find more information at Microsoft developer network web site http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_resources.asp .

The Windows APIs used for serial port communication are listed below. They are all supported in Ch.

CreateFile()
SetupComm()
GetCommState()
CommState()
BuildCommDCB()
SetCommTimeouts()
WriteFile()
ReadFile()
The sample files can be found at http://groups.yahoo.com/group/ch_language/files/SerialDemo/ and Ch Bhand package http://chbhand.sourceforge.net

Q: How to call functions in a Windows DLL library from Ch?

Ch cannot use LoadLibrary() and GetProcAdr() with .DLL file to call functions in a DLL library directly. Special handling is required. It doesn't require to modify your C/C++ source code.
You can find the sample code at the directory:
C:\ch\toolkit\demos\SDK\chapters\runc2chf_dll\chf

Q: How to catch any keys in Windows?

You can use function kbhit(). Here is the sample code.

#include <conio.h> int main() { char c; printf("hit a key\n"); while (!kbhit()) ; // Waits for keystroke while (kbhit()) c= getch(); // Empties buffer //while (!kbhit()) // ; // Waits for keystroke printf("you hit the key = '%c'\n", c); }

Q: How to generate plotting using a static SIGL library?

To link a static SIGL library, in the files

C:/silib/demos/chapter2/Makefile C:/silib/demos/chapter3/Makefile Change CFLAG=-I"C:/silib/include" -DM_PI=3.14159265358979323846 LFLAG="C:/silib/lib/libchplot.lib" to CFLAG=/MD -I"C:/silib/include" -DM_PI=3.14159265358979323846 LFLAG="C:/silib/lib/libchplot_a.lib" to use static lib libchplot_a.lib in Windows.

Q: How to zoom back to the original plotting in Ch Pro or SIGL after zooming out?

You can zoom in or zomm out by holding and dragging with the right mouse button.

To zoom in, move the mouse while holding down the right mouse button, It will report the upper left and lower right corners of the zoom. While the mouse is focused on the plot, type 'p' will go back the previous zoom stack, and type 'n' will to the next zoom stack. You can pay attention to 'a' and 'u' keys.