473,786 Members | 2,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

umanaged code - array error

dim s_err as stringbuilder
dim xx(6) as double
dim ret_flag as integer

' This is a function to call an unmanaged C-style library function.
' The lib function fills an array of 6 doubles or error string.

Declare Auto Function calc Lib "calc32.dll " Alias "calc32.dll "( ByRef xx()
As Double, ByVal serr As System.Text.Str ingBuilder) As Integer

' Using the unmanaged function:

ret_flag = swe_calc(tjd_et , planet, iflag, xx(6), serr)

If I take out the 6 in the above line, I get error "number of indices is
less than the number of dimensions in the indexed array."

If I put it in, or put a zero in, like xx(0) or xx(6), I get the error
"value of type double cannot be converted to '1 dimensional array of
double'"

What is wrong here? TIA

--

Patrick Sullivan, AA-BA, BA-IT
May 8 '06 #1
4 4846
dim s_err as stringbuilder
dim xx(6) as double
dim ret_flag as integer

' This is a function to call an unmanaged C-style library function.
' The lib function fills an array of 6 doubles or error string.

Declare Auto Function calc Lib "calc32.dll " Alias "calc32.dll "( ByRef xx()
As Double, ByVal serr As System.Text.Str ingBuilder) As Integer

' Using the unmanaged function:

ret_flag = swe_calc(xx(6), serr)

If I take out the 6 in the above line, I get error "number of indices is
less than the number of dimensions in the indexed array."

If I put it in, or put a zero in, like xx(0) or xx(6), I get the error
"value of type double cannot be converted to '1 dimensional array of
double'"

What is wrong here? TIA


May 8 '06 #2

Patrick Sullivan wrote:
dim s_err as stringbuilder
dim xx(6) as double
dim ret_flag as integer

' This is a function to call an unmanaged C-style library function.
' The lib function fills an array of 6 doubles or error string.

Declare Auto Function calc Lib "calc32.dll " Alias "calc32.dll "( ByRef xx()
As Double, ByVal serr As System.Text.Str ingBuilder) As Integer

' Using the unmanaged function:

ret_flag = swe_calc(xx(6), serr)
Copy-and-pasting code is a much more reliable way of showing us your
code. Note that the Declare calls the function 'calc' but you call it
as 'swe_calc'. If we have to guess what you mean, it will take us
longer to help you.

If I take out the 6 in the above line, I get error "number of indices is
less than the number of dimensions in the indexed array."

If I put it in, or put a zero in, like xx(0) or xx(6), I get the error
"value of type double cannot be converted to '1 dimensional array of
double'"


Try

ret_flag = calc(xx, serr)

The function wants an array: it is xx - not xx(0) or xx(6) or xx() -
that is an array.

Also, xx should be initialised to an empty array before calling the
DLL, otherwise there will be nowehere to put the results:

xx = New Double(6) {}

Also also, all I have fixed is the syntax: I don't know enough about
calling unmanaged code to be able to say that this will definitely do
what you want.

--
Larry Lard
Replies to group please

May 8 '06 #3
Thanks Larry. You figured out what I wanted to know, I think. Interop is
kind of confusing. It took me quite a while to get the s_err to pass
compiling.

--

Patrick Sullivan, AA-BA, BA-IT

"Larry Lard" <la*******@hotm ail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...

Patrick Sullivan wrote:
dim s_err as stringbuilder
dim xx(6) as double
dim ret_flag as integer

' This is a function to call an unmanaged C-style library function.
' The lib function fills an array of 6 doubles or error string.

Declare Auto Function calc Lib "calc32.dll " Alias "calc32.dll "( ByRef xx() As Double, ByVal serr As System.Text.Str ingBuilder) As Integer

' Using the unmanaged function:

ret_flag = swe_calc(xx(6), serr)


Copy-and-pasting code is a much more reliable way of showing us your
code. Note that the Declare calls the function 'calc' but you call it
as 'swe_calc'. If we have to guess what you mean, it will take us
longer to help you.

If I take out the 6 in the above line, I get error "number of indices is
less than the number of dimensions in the indexed array."

If I put it in, or put a zero in, like xx(0) or xx(6), I get the error
"value of type double cannot be converted to '1 dimensional array of
double'"


Try

ret_flag = calc(xx, serr)

The function wants an array: it is xx - not xx(0) or xx(6) or xx() -
that is an array.

Also, xx should be initialised to an empty array before calling the
DLL, otherwise there will be nowehere to put the results:

xx = New Double(6) {}

Also also, all I have fixed is the syntax: I don't know enough about
calling unmanaged code to be able to say that this will definitely do
what you want.

--
Larry Lard
Replies to group please

May 8 '06 #4
You are declaring an array of 7 doubles. To declare an array of 6
doubles, you have to do like this:

dim xx(5) as double

Patrick Sullivan wrote:
dim s_err as stringbuilder
dim xx(6) as double
dim ret_flag as integer

' This is a function to call an unmanaged C-style library function.
' The lib function fills an array of 6 doubles or error string.

Declare Auto Function calc Lib "calc32.dll " Alias "calc32.dll "( ByRef xx()
As Double, ByVal serr As System.Text.Str ingBuilder) As Integer

' Using the unmanaged function:

ret_flag = swe_calc(xx(6), serr)

If I take out the 6 in the above line, I get error "number of indices is
less than the number of dimensions in the indexed array."

If I put it in, or put a zero in, like xx(0) or xx(6), I get the error
"value of type double cannot be converted to '1 dimensional array of
double'"

What is wrong here? TIA

May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2970
by: Marc Schellens | last post by:
Following the NumPy documentation, I took over some C code, but run into an error. Does anybody have a suggestion? Thanks, marc gdlpython.cpp:225: `PyArray_Type' undeclared (first use this function) #include <python2.3/Python.h>
16
4229
by: Jason | last post by:
Hi, I need a way to use random numbers in c++. In my c++ project, when using the mingw compiler I used a mersenne twister that is publicly available and this did its job well. Now I have shelled out on VC++ 6.0 compiling that same code is proving difficult. I am not too worried how I generate random numbers in c++, as long as it is sufficiently random. Can anybody help me out in getting what I want from VC++?
2
2215
by: JRoe | last post by:
Hello, I am beside myself with this problem. I need to access unmanged C++ code in a C# environment. I have created a managed C++ wrapper that wraps the unmanaged class. When I call the constructor, it is returning undefined. Here is an example: Unmanaged C++ class Map_Interface
2
1556
by: Sugan | last post by:
Hi All, I have a peculiar kind of issue after converting VC and VB code from Visual studio 6.0 to Visual Studio 2005. We have the business logic in the VC code which uses the ATL framework and implements a COM server. VB code gives the GUI part of the project, For reporting custom errors like invalid login, we use AtlReportError method to report error from the VC code side.
0
1300
by: Sugan | last post by:
Hi All, I have a peculiar kind of issue after converting VC and VB code from Visual studio 6.0 to Visual Studio 2005. We have the business logic in the VC code which uses the ATL framework and implements a COM server. VB code gives the GUI part of the project, For reporting custom errors like invalid login, we use AtlReportError method to report error from the VC code side.
2
2708
by: =?Utf-8?B?VG9ub2ZpdA==?= | last post by:
I've got the following umanaged code that I need to handle in C# code. The data I read comes from an external device, by Read(ID, &data, REGLEN); How should the code look for the structs in C# to handle "PULONG Value" in the function call and the "PktArray.pbyBuf = (PUCHAR)&regAddr;" "PktArray.pbyBuf = (PBYTE) pValue;" statement in C# so I get read data from an external device? *******Code******
1
2269
by: dileepd | last post by:
Hi Every one, Could you please let me know if you have any clue about following things. 1. Whether type bool acts like a kind of signed int type in g++ on solaris 9(a/c to my invetsigation it is "Yes"). 2. If above question is yes,What needs to be done in order for compiler to overload constructor once with bool and one with integer. Iam asking these question as iam encountering following errors.
14
3796
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain more why C++/CLI would be better to PInvoke than doing the PInvoke in C#? Because, usually in C# as you already know we use DLLImport and extern
0
1752
by: dprjessie | last post by:
Hello, I am a Web programmer and I'm working on my first desktop application as a favor for a friend. I'm sure I have a stupid error here, but there is no error being thrown so I can't figure out what is wrong. I have code that reads an excel file and fills a datagridview and it works just fine. It is also supposed to fill a database though and that is not working. The executeNonQuery command is returning a 1 which as I understand, means it has...
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.