News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Is the truth true or false ;-)

Started by Juergen, August 22, 2014, 12:47:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Juergen

I am running the textjus.d3m example with success,
in the clipboard are the right value (0.000 , 1.000 or 2.000)

        Dim gotjust As Boolean
        Dim bool As Boolean
        Dim a As String

        a = myfolder + "\textjus.d3m"
        '  MsgBox(a) 'Contains the correct full path

        gotjust = DcDoc.RunBasicCAD(a)
        MsgBox(gotjust)
      
I am wondering why the result of gotjust is 'false',
is there something wrong with the syntax?

Kind regards and thanks for any advice,

Juergen

DrollTroll

It's hard to say. Try setting DesignCAD's Application.ErrorCode property to 0 just before your RunBasicCAD logic, then check its value immediately after you get a False result.
25 years with DesignCAD

Juergen

It's a bit weird. This code

   a = myfolder + "\textjus.d3m" 'myfolder is public - a is string
        DcApp.ErrorCode = 0
        gotjust = DcDoc.RunBasicCAD(a)
        MsgBox(DcApp.ErrorCode)
        MsgBox(gotjust)
      
results in an errocode=0 (docu says: 0 = Command Complete)
So gotjust should be True? - the macros was executed.

Also tried:
MsgBox(gotjust)
MsgBox(DcApp.ErrorCode)

Thank and kind regards,

Juergen

DrollTroll

Seems strange. Do you get the same error if a is simply the full path to the macro, rather than doing the string concatenation?
25 years with DesignCAD

Juergen

Both calls:

a = "textjus.d3m"
gotjust = DcDoc.RunBasicCAD(a)

gotjust = DcDoc.RunBasicCAD("textjus.d3m")

result in errcode=0 and False. The macro
is executed.

Juergen

DrollTroll

OK, could be a coding error that has crept in due to version creep. I'll look into it.

Try this though -- intentionally try to run a nonexistent BasicCAD program. Ignore the return value, and check the error code -- does that help you better identify potential issues?
25 years with DesignCAD

Juergen

Calling a non existing macro leads immediately to a DC Alert "Command failed".
Errorcode still 0 (strange), gotjust is False.
I'll check the behavior in DC 23 soon.

Kind regards,

Juergen

Juergen

OK, I have installed DC 23 trial on another PC and I can confirm that a VBE program with DC22 library runs fine on DC23.
The behavior regarding RunBasicCAD (false) and errorcode=0 is the same.

Regards,

Juergen

Juergen

I just realized that I have installed V21 on another PC. The VBE OLE code snippet created with DC22(!) runs on DC 21 as well.
Returncode and errorcode fail again.

Juergen

DrollTroll

It's entirely possible that the documentation (return code FALSE if the macro fails to run) was just a case of "I'd like this to happen" when I wrote the documentation. Maybe that result never worked as intended and nobody caught it until now.

If I get a chance I'll try it on some earlier versions, like V13, V14, V15 and see how they do.
25 years with DesignCAD

Juergen

> I'll try it on some earlier versions

Please don't bother. However, there must be a chance to verify the macro is executed (with the current version).
I'll play around with the errorcode. BTW: I have installed V20 on a virtual engine - my OLE code snippet (build with V22)
failed (DC not started).

Kind regards,

Juergen

Juergen

> BTW: I have installed V20 on a virtual engine - my OLE code snippet (build with V22) failed (DC not started).

Sorry, I realized this too late "Also: I'd suggest you make version 21 your earliest supported version,"
So the earliest versions to support (using OLE Automation) should be V21, this is reasonable.

Regards,

Juergen

prl

Quote from: Juergen on August 23, 2014, 03:20:55 AM
However, there must be a chance to verify the macro is executed (with the current version).

Before your macro ends, you could have it write something to the clipboard and have your compiled program read, process the message, and clear the clipboard.

.
.
.
sys$(40)="Routine 13432 Done"
End

DrollTroll

Looks like you're using the clipboard already, so here's an alternate suggestion:
Before running the macro, have your OLE Automation function write "failed" to SysEx$(1) (for example).
Then sometime while your macro is running, write "passed" to the same SysEx$().
After the macro should have run, have the Ole Automation program read that SysEx$ value. If it says "failed", the macro didn't execute.

This could of course be expanded to have the macro itself report various errors if it encounters any, but I think you get the basic idea.

Note that there are no direct OLE methods to read the SysEx$ values -- you have to manually load them from the appropriate ini file and look for the correct value.

Here's the overview from the OleDc17.hlp file:

The SysEx$ functions are string variables that are stored in text files and are therefore remembered between DesignCAD sessions. There are 10,000 strings available: SysEx$(1) – SysEx$(10000). The variables are stored in files of 100 each, as follows:
SysStr_001.ini stores SysEx$(1) – SysEx$(100).
SysStr_002.ini stores SysEx$(101) – SysEx$(200)
etc. through
SysStr_100.ini stores SysEx$(9901 – SysEx$(10000)

All SysStr ini files can be cleared by running the ClearStorage$ statement with no arguments.

An individual SysStr ini file can be cleared by running ClearStorage$ n, where n is the number in the ini file's name. For example,
ClearStorage$ 100
clears SysStr_100.ini, thereby clearing all values from SysEx$(9901) – SysEx$(10000).


So for SysEx$(1), you'd have to load SysStr_001.ini, and look for a line beginning with "I-1=". The rest of that line is your string.

I'm attaching a sample macro and the resulting SysStr_001.ini so you can see the formatting of the file -- it's basically a standard INI file with a [SYSEX$] section header. Feel free to experiment further.

Or of course, if you don't want to mess with these INI files directly, just create your own text file and write to it from OLE automation, then from BasicCAD, then read it back with OLE Automation.
25 years with DesignCAD

Juergen

Prl and DrollTroll,

Thank you for giving me a jumpstart in this matter. Both solutions are suitable as the case may be.

So I see the truth is still true ;-)

Kind regards,

Juergen