Highlighted
Absent Member.
Absent Member.
845 views

[archive] OCX Method not performed

[Migrated content. Thread originally posted on 13 September 2005]

An OCX-control has the following Method declared in the def-file :

      * PreTare
               METHOD, 18, @PreTare,
                   "double" @NewTareValue, TYPE 5,
                   "unsigned char" @NewTareUnit, TYPE 17,
                   "short*" @ScaleStatus, TYPE 16386
                       RETURNING "boolean", TYPE 11


Working-Storage :

       77 SA-BOOLEAN       PIC S9.
       77 WTARRA           PIC ---,-.
       77 SA-NEWTAREVALUE  USAGE IS DOUBLE.
       77 SA-NEWTAREUNIT   PIC  X.
       77 SA-SCALESTATUS   PIC  S9(4) USAGE IS COMP-5.


Procedure :

       SET-TARRA-CLICK.
           PERFORM TARRA00 THRU TARRA99.
       TARRA00.
           MOVE WTARRA          TO SA-NEWTAREVALUE.
           MOVE 2               TO SA-NEWTAREUNIT.
           MODIFY WEEGSCHAAL, @PreTare(
                  BY NAME NewTareValue SA-NEWTAREVALUE
                  BY NAME NewTareUnit SA-NEWTAREUNIT
                  BY NAME ScaleStatus SA-SCALESTATUS)
                  RETURNING SA-BOOLEAN.
       TARRA99.


WTARRA has a value of 16,5
SA-SCALESTATUS returns a value, determining a certain status like PreTare not performed.

Executing this procedure, the control gives an error.
Any ideas ?
0 Likes
9 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed

Read section 6.10.2.2 and 3.8.1 of the ACUCOBOL-GT 6.2 User's Guide and the MODIFY verb format 1 syntax for paramter expressions. What you will find is that @ScaleStatus needs to be passed by reference which you can do by using a type code.

BY NAME ScaleStatus SA-SCALESTATUS AS 2
- or -
BY NAME ScaleStatus SA-SCALESTATUS AS VT-I2

The latter requires the activex.def copy file.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed

Dan_M,
Thanks for your quick reply but this doesn't seem to work.

I invoced another method of the control with ScaleStatus and this works just fine

Def-file :

      * Zero
      * Zero?s the scale. Returs success(true) or failure(false)
               METHOD, 43, @Zero,
                   "short*" @ScaleStatus, TYPE 16386
                       RETURNING "boolean", TYPE 11


Procedure :

           MODIFY WEEGSCHAAL, @Zero(
                  BY NAME ScaleStatus SA-SCALESTATUS)
                  RETURNING SA-BOOLEAN.


I think it's something to do with the value of WTARRA.
I send f.i. 16,5 and the scale expect 16,50 .. don't know.

Included the DEF-file of the control.
Hope you can help me out here.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed

Ask yourself some questions and get the answers. For instance, what value is in your double after you move the numeric-edited WTARRA to it(perhaps moving numeric-edited to double is a problem, I'm not sure, the runtime should be de-editing first)? What values is the the control expecting for that field? What exactly is the full error your getting, and does the control documentation explain what the error means?

If you need to shift the number up by another factor of 10 then multiply the double by 10 before invoking the method. ie. 165 becomes 1650
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed

Let me just make one thing straight, do not get blind when staring at the ax datatypes. The runtime does conversions on the fly, no need to try to match the remote datatypes.

Thus; Use ordinary pic 9(n)v9(n) values as you desire.

Do you have an example of how to use this from any other language?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed


// with wrapper class
void main ()
{
   double               dNewTareValue;
   unsigned char        ucNewTareUnit
   short*               sScaleStatus;
   VARIANT_BOOL         result;

   result = MTActiveWeight1->PreTare(dNewTareValue,
                                     ucNewTareUnit,
                                     &sScaleStatus);
}

// without wrapper class
void main ()
{
   double               dNewTareValue;
   unsigned char        ucNewTareUnit
   short*               sScaleStatus;
   VARIANT_BOOL         result;
   HRESULT hr;

   hr = MTActiveWeight1->Pretare(dNewTareValue,
                                 ucNewTareUnit,
                                 &sScaleStatus,
                                 &result);
   if(FAILED(hr))
   {
       // COM error
       // Function has not been successful executed
   }

   if(result == false)
   {
       // Error
       // Function has not been successful executed
       // check LastError
   }
}
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed

Two questions:

What is the error code you get?

May I see a complete program (not with file access and everything, but a full program with COPY .def file and CREATE and everything)?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed

The error I talk about, is when I call the function 'PreTare', the program enters declaratives so I guess I can call 'LastError' but nothing happens. LastError = 0

Zip-file included with ocx etc.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed

You cannot call LastError when an exception happens. Well, at least normally not.

When an exception happens, that usually indicates that there is a problem that the component cannot handle. Like for instance if you called a method that did not exist or if you made an instruction that would generate a division by zero.

There is a special interface to use to get exception errors. Please find attached the ExcepDemo.cbl from my Adv. Win class. Try implement that, and tell me what error code you get there.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] OCX Method not performed

One shot in the dark;

It might be that the method you are invoking that generates the error is not available with the license for which you invoke the component with. That is, a socalled designtime method.

You might want to check that with the vendor.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.