Automation/Safearray

slj
Member Posts: 6
Hi...
I'm trying to call a function in an automation called ImageMagick. The function has the following signature:
[VARIANT Convert :=] ImageMagick.Convert(VAR SAFEARRAY pArrayVar)
How do I pass the parameter "VAR SAFEARRAY pArrayVar" from C/AL? Which C/AL datatype am I supposed to pass? As far as I can figure from a Visual Basic code sample it is a function, which takes a variable number of arguments of type string.
/Stefan
I'm trying to call a function in an automation called ImageMagick. The function has the following signature:
[VARIANT Convert :=] ImageMagick.Convert(VAR SAFEARRAY pArrayVar)
How do I pass the parameter "VAR SAFEARRAY pArrayVar" from C/AL? Which C/AL datatype am I supposed to pass? As far as I can figure from a Visual Basic code sample it is a function, which takes a variable number of arguments of type string.
/Stefan
0
Comments
-
So have you tried to define a variable of Text data type and set its property Dimemsion to value bigger then 1?
What happend?®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
Yes, I have tried that...
The following code...
CREATE(ImageMagick);
TextArray[1] := 'logo:';
TextArray[2] := '-format';
TextArray[3] := '10,20,30';
TextArray[4] := 'logo.jpg';
ImageMagick.Convert(TextArray);
...produces a runtime error: "The array dimensions must be identical".
ImageMagick is the automation and TextArray is a text array with dimensions 4. I have tried different array dimensions.
The following VB code seems to be working:
Set img = CreateObject("ImageMagickObject.MagickImage.1")
msgs = img.Convert("logo:","-format","%m,%h,%w","logo.jpg")
One idea is to pass the array using the Variant datatype, but anyone who knows how I do that? The following code does not work:
CREATE(ImageMagick);
TextArray[1] := 'logo:';
TextArray[2] := '-format';
TextArray[3] := '10,20,30';
TextArray[4] := 'logo.jpg';
VariantVar := TextArray;
ImageMagick.Convert(VariantVar);
It produces a runtime error: ":= cannot be performed on arrays. Choose a single array value using an expression such as: MyArray[...]".
/Stefan0 -
what if you try:
ImageMagick.Convert(TextArray[1],TextArray[2],TextArray[3],TextArray[4]);
If not, maybe you can try to find out what is the limit of the array in VB. For sure it is not "that unlimited". There must be some nice big number...
Write a code in VB and call the function each time with one parm more. (I don't know how exactly should this look like in VB)®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
It gives a compilation error:
A maximum of 1 parameters must be used when calling the function. For example:
MyFunc( .. , .. , .. )
ROUND(MyVar)
ROUND(MyVar,0.05)
/Stefan0 -
slj wrote:It gives a compilation error:
A maximum of 1 parameters must be used when calling the function. For example:
MyFunc( .. , .. , .. )
ROUND(MyVar)
ROUND(MyVar,0.05)
/Stefan
We need to import BMP to jpg or gif in NAvision.
I have got the same problem with convert function.
Is anybody knows where is answer? ](*,)0 -
Hi Alex,
Yes we've had the same problem ...
The SAFEARRAY is used as a kind of variable argument list. Unfortunately, Navision cannot map SAFEARRAY types to one of its internal variables. (as stated in the Admin Guide)
We have programmed a tiny OCX, which works like a wrapper to other Automation Controllers. With this, you can invoke ImageMagick with the following Code:OW.CreateObjectByName (IM, 'ImageMagickObject.MagickImage.1'); OW.SetParam (1, 'logo:'); OW.SetParam (2, 'c:\temp\logo.jpg'); OW.CallMethod (Val, IM, 'Convert', 2);
See upload section (dbOleWrap) for the first Beta-release of this OCX. Please test and send me your comments.
In the hope, that it is helpful - Gunter0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions