| gclib 1.35.5 Communications API for Galil controllers and PLCs |

Borland C++

The following instructions were performed on:

    Embarcadero C++ 7.10 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.

For brevity, these instructions assume the default installation location of "C:\Program Files (x86)\Galil\gclib".

# Copy Files

Copy "gclib\examples\borland" to a convenient, writable location, e.g. "C:\temp". Run `C:\temp\borland\copy_source.bat` to copy all files.

    C:\temp>cd borland

    C:\temp\borland>copy_source.bat
    \Program Files (x86)\Galil\gclib\examples\cpp\x_arrays.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_examples.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_examples.h
    \Program Files (x86)\Galil\gclib\examples\cpp\x_gcommand.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_ginterrupt.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_gmessage.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_gmotioncomplete.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_gread_gwrite.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_grecord.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_nonblocking.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_programs.cpp
    \Program Files (x86)\Galil\gclib\examples\cpp\x_simple.c
           12 file(s) copied.
    \Program Files (x86)\Galil\gclib\include\gclib.h
    \Program Files (x86)\Galil\gclib\include\gclibo.h
    \Program Files (x86)\Galil\gclib\include\gclib_errors.h
    \Program Files (x86)\Galil\gclib\include\gclib_record.h
            4 file(s) copied.
    \Program Files (x86)\Galil\gclib\lib\dynamic\x86\gclib.lib
    \Program Files (x86)\Galil\gclib\lib\dynamic\x86\gclibo.lib
            2 file(s) copied.
    \Program Files (x86)\Galil\gclib\dll\x86\gclib.dll
    \Program Files (x86)\Galil\gclib\dll\x86\gclibo.dll
            2 file(s) copied.

    C:\temp\borland>

# Modify Path

- Add Borland's compiler to the `PATH` variable.

    C:\temp\borland>set PATH=c:\Program Files (x86)\Embarcadero\Studio\17.0\bin;%PATH%

# Convert lib files

    C:\temp\borland>move gclib.lib _gclib.lib
        1 file(s) moved.

    C:\temp\borland>move gclibo.lib _gclibo.lib
        1 file(s) moved.

    C:\temp\borland>coff2omf.exe _gclib.lib gclib.lib
    COFF to OMF Converter Version 1.2.0 Copyright (c) 1999-2009 Embarcadero Technologies, Inc.
    All rights reserved.

    C:\temp\borland>coff2omf.exe _gclibo.lib gclibo.lib
    COFF to OMF Converter Version 1.2.0 Copyright (c) 1999-2009 Embarcadero Technologies, Inc.
    All rights reserved.

# x_simple.c

## Edit GOpen() call as necessary

In a text editor, open x_simple.c. Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options.

## Compile

    C:\temp\borland>bcc32 gclib.lib gclibo.lib x_simple.c
    Embarcadero C++ 7.10 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
    x_simple.c:
    Turbo Incremental Link 6.72 Copyright (c) 1997-2015 Embarcadero Technologies, Inc.

## Execute

    C:\temp\borland>x_simple.exe
    version: 130.115.279
    info: 192.168.0.43, DMC4143 Rev 1.2b, 9998
    response:  61016.0000
    :

# x_examples.cpp

## Review and Modify source

- In a text editor, open x_examples.cpp. Find the GOpen() call and update the address to match the desired hardware. See the documentation for GOpen() for address formatting options.
- Find the `#if 0` preprocessor block enclosing the example calls. Change to `#if 1` to run the examples. Comment out the function calls to be avoided. Note some calls attempt to move motors and not all functions are compatible with all Galil products.

## Compile

    C:\temp\borland>bcc32 -c  *.cpp

## Link

    C:\temp\borland>bcc32 -o examples.exe *.obj gclib.lib gclibo.lib

## Execute

    C:\temp\borland>examples.exe
    Library version: 130.115.279

    192.168.0.43, DMC4020 Rev 1.2b, 291

    ************************************************************************
    Example GRead() and GWrite() usage
    ************************************************************************

    Read 155 QR bytes.

    ************************************************************************
    Example GCommand() usage
    ************************************************************************
    Revision report, ^R^V
    DMC4020 Rev 1.2b
    :

    Command Values
    val is 10
    val is 11
    val is 3.1415
    val is 9.869

    Command Trimming
    > 95653016.0000
    :<
    > 95653016.0000<
    >95653016.0000<

    Receiving Binary Data
    QR read 155 bytes

    Error handling
    QD correctly trapped, not allowed, try GArrayDownload()
    DL correctly trapped, not allowed, try GProgramDownload()

    Modifying timeout
    Burning program...OK

    ************************************************************************
    Example GProgramDownload() and GProgramUpload() usage
    ************************************************************************
    GProgramDownload() correctly errored. Can't fit with level 3 compression
    Program Downloaded with compression level 4
    Uploading program:
    #A;i=0;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i
    i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;i=i+1;EN

    Program executed as expected
    ************************************************************************
    Example GArrayDownload() and GArrayUpload() usage
    ************************************************************************
    2.0000, 4.0000, 6.0000, 8.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.000
    0000

    2.0000, 1.0000, 3.0000, 5.0000, 10.0000, 12.0000, 14.0000, 16.0000, 18.000
    0000

    3.0000, 5.0000, 10.0000

    ************************************************************************
    Example GRecord() usage
    ************************************************************************

    QR-based data record
    38564
    393216000

    DR-based data record
    38670
    38772
    38874
    38976
    39078
    39180
    39282
    39384
    39486
    39588
    39690

    QR-based data record with offsets
    39692
    39692

    ************************************************************************
    Example GMessage() usage
    ************************************************************************
     0.0000
     1.0000
     2.0000
     3.0000
     4.0000
     5.0000
     6.0000
     7.0000
     8.0000
     9.0000

    ************************************************************************
    Example GInterrupt() usage
    ************************************************************************
    "UI 8" executed.

    ************************************************************************
    Example GMotionComplete() usage
    ************************************************************************

    Position: 0, 0
    Beginning independent motion... Motion Complete on A
    Position: 8000, 0

    Position: 0, 0
    Beginning vector motion... Motion Complete on vector plane S
    Position: 6000, 0

    examples.cpp executed OK
    main() is finished. Press Enter to exit: