C10: Adding StringTheory to a Hand Coded project

Another newbie question.

I have a simple hand coded project called Fixer
Capture

It consists of a single clw file and includes match.cpp from the SHOWIMG example file at SoftVelocity\Clarion10\Examples\SRC\SHOWIMG

Now I want to do some string manipulation using StringTheory. The instructions are:

Using StringTheory in a Hand-Coded Project

To add StringTheory to a hand-coded project (with no APP and hence no Global Extension template) do the following;

  1. Add
    include(‘StringTheory.Inc’),Once
    to your main module
  2. Add the StringTheoryLinkMode and StringTheoryDllMode project defines to your project. Set
    StringTheoryLinkMode=>1
    if the class should be linked into the project, and
    StringTheoryDllMode=>1
    if the object is exported from another DLL.

You can declare StringTheory objects in your code by simply doing;

str StringTheory

I understand (1.) above and did it. I have no idea about (2.) I don’t know what it means, for starters, or where to go in C10 do do it.

Please could someone give me some step-by-step instructions? Maybe by the time I’ve done them I’ll have a better understanding or what I just did. :thinking:

Hi Don,

First off, you can think of these settings (project defines) as a sort of constant. By convention The *LinkMode and *DLLMode are (nearly?) always used by the MODULE and LINK attributes of a class. Other defines are commonly used for conditional OMITs and COMPILEs.

More advanced detail: The advantage to setting these defines at the project level vs. as an equate, is that they scope to all files in the project whereas (even a global) an equate might not - this is the case, when you have MEMBER() statement, with nothing between the parenthesis. Such code can be used by many projects, vs. being tied to a particular one. StringTheory.clw is an example of such code.

There are a few ways to add the project defines to your project.

  1. In the solution explorer (the image you posted above),
    right click on the ‘Fixer’ row and select Properties
    then go to the Compiling Tab
    then add the following to the ‘Conditional Compilation Symbols’ entry
    StringTheoryLinkMode=>1;StringTheoryDLLMode=>0
    NOTE: you can click the ‘…’ button
    to show the ; delimited list as a browse, with add / edit / remove buttons

  2. In the solution explorer window, right click on the ‘Projects to include’ line
    and select “add project to include” create a filename with a .PR or .PRJ extension
    in the file add the following lines
    #pragma define(StringTheoryLinkMode=>1)
    #pragma define(StringTheoryDLLMode=>0)

  3. In source (at the appropriate spot) write
    pragma(‘define(StringTheoryLinkMode=>1)’)
    pragma(‘define(StringTheoryDLLMode=>0)’)

    that said, I don’t think there really is an appropriate spot in this case

Also note you can replace
the =>1 with =>on and
the =>0 with =>off
in all of the ways mentioned above,
both notations are identical,
just pick the one that you prefer.

Personally, I tend to use choice #2, mainly because I find it more readable than choice #1.
The Choice #3 technique I reserve for some special pragmas (like profile, and init_priority) where the setting only applies to certain modules. Note: In the solution explorer, you can right click on a module (ex: yada.clw) and select properties, from there you you an fill in DEFINES. These will be module level defines the like the ones I use Choice #3 to accomplish. Here I like Choice #3, as it’s clearer to me that the setting is present.

The same techniques apply to APPs, however to solve certain problems, folks sometimes recommend deleting the .CWPROJ and letting the APP rebuild it. In which case the choice #1 settings are lost.
I recommend putting any pragma’s that will not be automatically recreated by the APP into a .PR or .PRJ file (choice #2 above).

NOTE: *LinkMode and *DLLMode should always have different values.
use LinkMode=>0; DLLMode=>1 when using code exported from another DLL
use LinkMode=>1; DLLMode=>0 all other times

2 Likes

Wouldn’t have thought of the “projects to include” for this particular thing. Good idea. That will save me a bit of time, as I usually use the same basic toolbox

Thanks.

I can see how this whole concept would all be as clear as mud for some folks trying to learn it though.

Here are some screenshots of Mark’s option 1.

And here’s the window that pops up where you can edit the defines like a table.

image

3 Likes

Thank you Mark and Jeff for taking the time to answer this.
I put the PRAGMA lines just below the INCLUDE and it is all working

INCLUDE('StringTheory.Inc'),Once                        ! String Theory (c) CapeSoft
PRAGMA('define(StringTheoryLinkMode=>1)')
PRAGMA('define(StringTheoryDLLMode=>0)')

I wouldn’t use choice #3, as there is an issue of scope
I was just including it, to be complete about ways to set pragmas

see above when describing choice #3, where I wrote:

that said, I don’t think there really is an appropriate spot in this case

1 Like

Yes you are right. I commented out the PRAGMA lines and because I had already done #1 the program still works correctly.

Thanks once again.