Assign global array of structures of structures of std strings in a dll
I have a dll which consists of three c files. Find bellow the c file of the loader and the three files of the dll. In dll, file 1 and file 2 are almost identical, static arrays names and sizes, structure names, Prepare_1() and Prepare_2() functions. There
is a small difference in the function Prepare_1 in the way MuxStatusSupl[ u32Idx ].FileInfo.Name is assigned and there I get an exception. Another difference is that the structure StructStatus in file 2 has an extra member compare to file 1. From this point
I couldn't strip down even more the sample code because small changes make the problem disappear without, I'm afraid, really solving the problem. That's why I have put so much code here, I'm not even sure what is relevant and what not. For example, if I add
in file 1 in the StructStatus the extra member u32ExitPoint (and, of course, I modify Status_Init accordingly), I don't see the problem anymore.
///////////////////////////////////////////////////// loader file begin ////
#include "stdafx.h"
int main(int argc, char* argv[])
{ HINSTANCE hDLL = LoadLibrary( DLL_FQN_FILE_NAME );
if( void ( * pCreateDllInterface )( void ) =
(void(*)())GetProcAddress( hDLL, "CreateDllInterface" ) )
pCreateDllInterface();
FreeLibrary( hDLL );
///////////////////////////////////////////////////// loader file end //////
///////////////////////////////////////////////////// dll main file begin //
extern void Prepare_1( void );
extern void Prepare_2( void );
extern "C" _declspec(dllexport) void CreateDllInterface( ) { Prepare_1(); }
///////////////////////////////////////////////////// dll main file end ////
///////////////////////////////////////////////////// dll file 1 begin /////
#include <string>
#include <sys/stat.h>
#define STORAGE_SIZE 254
typedef unsigned long int uint32;
struct StructFileInfo
{ std::string Name;
struct stat FileStatus;
static struct StructStatus
{ bool bDownloaded; bool bDownloadedLast;
bool bCalled; bool bCalledLast;
uint32 u32EntryPoint;
StructFileInfo FileInfo;
} MuxStatusMain[ STORAGE_SIZE ], MuxStatusSupl[ STORAGE_SIZE ];
void Prepare_1()
{ struct stat Stat_Init;
memset( &Stat_Init, 0, sizeof(struct stat) );
StructStatus Status_Init =
{ false, false, false, false, 0, { "", Stat_Init } };
std::fill_n( MuxStatusMain, STORAGE_SIZE, Status_Init ); // this seems
// to overwrite MuxStatusSupl[ 3 ].FileInfo.Name
for( uint32 u32Idx = 0; u32Idx < STORAGE_SIZE; u32Idx++ )
MuxStatusSupl[ u32Idx ].FileInfo.Name = ""; // crash when u32Idx==3
///////////////////////////////////////////////////// dll file 1 end ///////
///////////////////////////////////////////////////// dll file 2 begin /////
#include <string>
#include <sys/stat.h>
#define STORAGE_SIZE 254
typedef unsigned long int uint32;
struct StructFileInfo
{ std::string Name;
struct stat FileStatus;
static struct StructStatus
{ bool bDownloaded; bool bDownloadedLast;
bool bCalled; bool bCalledLast;
uint32 u32EntryPoint; uint32 u32ExitPoint;
StructFileInfo FileInfo;
} MuxStatusMain[ STORAGE_SIZE ], MuxStatusSupl[ STORAGE_SIZE ];
void Prepare_2()
{ struct stat Stat_Init;
memset( &Stat_Init, 0, sizeof(struct stat) );
StructStatus Status_Init =
{ false, false, false, false, 0, 0xFFFFFFFF, { "", Stat_Init } };
std::fill_n( MuxStatusMain, STORAGE_SIZE, Status_Init );
std::fill_n( MuxStatusSupl, STORAGE_SIZE, Status_Init );
///////////////////////////////////////////////////// dll file 2 end ///////
I get the crash with the message: Unhalted exception at 0x10001f90 in Test.exe: 0xC0000005: Access violation writing location 0x1006d320
Another strange phenomena is that in watch window, expressions
sizeof(MuxStatusMain)/sizof(MuxStatusMain[0])
sizeof(MuxStatusMain)/sizof(MuxStatusMain[0])
show both a value of 232 instead of 254 (but if I add in file 1 in the struct the missing member they show the correct values). On the other hand, if I printf those values, they are correct, 254.
"Another difference is that the structure StructStatus in file 2 has an extra member compare to file 1."
That's not going to work. It is possible to define the same struct in different translation units but the definitions need to be identical. Use different names for StructFileInfo and StructStatus.
Similar Messages
-
Loops in arrays or structures
I was given a project on html reports and
They have advised me to use Loops in arrays or structures
At this point I am a novice at this html reporting system. I
would like to know how I can use loops in arrays or structures.
How is it beneficial are
1. Structures
2. Arrays
3. loops in for both
for my reports.
Countless thanks in advanceStructures are great if you understand them, they are
basically just arrays organized by keywords rather than index
numbers.
Arrays are very nice, as you can just run through loops to
access each element, as they are all indexed by numbers 0-x.
loops are great to navigate through both. All you have to do
is set an loop to run through x amount of iterations of the array
or structure (where x is the length of the array, or number of
elements in the structure). Loops are great due to the small amount
of code they require. -
How to include the not assigned nodes in Hierarchy structure
Hi Experts,
I am running a report which has got Hierarchy variable type. After execution of the query some of the nodes appear always under "not assigned".
Please let me know is it possible to include these not assigned node under hierarchy structure.If so how to do that?
Regards
KumarHi Subbiah.
You can also supress the "not assigned" nodes in the hierarchy maintanence by choosing: Hierarchy attributes -> Supress unassigned nodes.
Hope it helps.
BR
Stefan -
How to create an array of structure which the structure contain an array(s)
im very new to java, and new here
i searched many websites, but i cant find it
it looks like this,
there is 10 employees, each of them has 0-5 children,
what i want is,
peter alan joseph
|?????????????????|???????|??????????????
| |????????| |??????| | |?????| |
| | andrew | | alvin | | | john | | ...........................
| |________| |______| | |_____| |
| |
what i know is,
import java.util.*;
class main{
public static void main(String[] args){
employee d[] = new employee[10];
d[0]= new employee();
d[0].child = "alvin";
System.out.println(d[0].child);
class employee{
String child;
}but only work for 1 child.. =(
i need an array of structure which the structure itself cantains an array(s)
please help, newbie heresen,
my lecture[r] said no statement in classEither you misundetstood your lecturer [probable]; or your lecturer is full of shit [possible].
is "String[] children = new String[5]" a statement ?Yes, it is.
she said we can only declare like "String[] children;" in classEither you misundetstood your lecturer ...
There's nothing actually wrong withclass Employee{
String[] children = new String[5];
}But it has the inherent limitation that you can't put the fathers name on the 6'th child's birth certificate... because the dumb computer won't let you... Hence it is poor practice.
A better implementation would be:class Employee{
private List<String> children = new ArrayList<String>();
}because it doesn't impose an artificial limit on the number of kids a bloke can have.
keith. -
Is there a way to pass an array or structure for example as parameters, in addition to a query, or multiple queries to the Report Builder in CF8? I believe this was recommended by users to be in CF8.
BrianO,
Although it's been a while, I thought I'd provide the code to do this for you. It works for me in CF8, and probably will in CF7.
Here I create a structure called My, and provide that one parameter to my CFReportParam tag.
<CFSet My = {
Client = "Client Name",
ReportDateFrom = DateFormat(ThisStartDate, DateMask),
ReportDateTo = DateFormat(ThisEndDate, DateMask),
PageHeaderImage = ImagePath & "\Logos\Page_Header.png",
WatermarkImage = ImagePath & "\Logos\Watermark.png",
GetBarSummary = GetBarSummary,
GetPieSummary = GetPieSummary
}>
<CFReport Template="#ReportPath#\SpendSummary.cfr" Format="PDF" Query="GetSummary">
<CFReportParam Name="My" Value="#My#">
</CFReport>
Inside the report itself, reference the given parameter as Param.My.PageHeaderImage for example. It can be referenced that way from any expression inside the report builder. You can even use the queries as the data source for charts (using the Data From a Query -> Query Builder -> Advanced) by entering "Param.My.GetPieSummary" where it says "Variable containing query object".
HTH
Swift -
Hello, I am working on a SAP CRM 7 Sales implementation and we are implementing leads and opportunity scenarios. The current business organization model is that there multiple vertical and horizontal departments. This is typical matrix structure. This organization has done the segregation of its clients based on the verticals so every clients belongs to at least one or more Vertical department but Horizontal departments can contact all the clients. In the same way sales executives are also either belonging to one or more Verticals or Horizontal departments? Horizontal sales executive can create leads for any clients available in the system but a Vertical sales executive can only create lead only for the client belongs to his vertical and assigned to him. This can be achieved by creating organization structure and business partner relationship.
Now the problem statement is that few sales executives need work for both some Verticals and Horizontals at the same time. But requirement is that they should be able to do the both roles with single user id but multiple roles. So when sales executive is creating leads his vertical department, he should only be able to select clients assigned to his Vertical only but when he is creating lead for Horizontal department, he should be able to select any clients.
So Can I determine the business partners linked to user based on the assigned role and org. structure?
Please let me know if this is not clear also note we are only using CRM WebUI no SAP ePortal.
Thanks a lot your help in advance.
Regards
Sudesh SharmaThanks, Tahir
my problem has solved
Kind Regards,
Faisal -
How to pass a structure/array of structure as input parameter in a webservice
Hi Team,
I am trying to create a webservice in powerbuilder .net( pb 12.5.1) . As this webservice will be used by external world to access some of data on basis of some input paarameter.
So can i use array of structure as input parameter to a webservice ? If no, then how can i pass a result set ( mora then 1 row with more than one column)
as an argument to the webservice.
Regards
SubratI am assuming this is the same for .Net but in Classic you can create NVO's with Instance Variables and then reference them in the NVO that will be used as the parameter for the Public WebService.
WS NVO's:
Children
String Child[]
Customer
String FirstName
String LastName
String DOB
Children Children
Public Interface uses Customer
Calling Code Example:
integer rc, liNdx
string lsReturn
SoapConnection lSoapConnect
proxy_testing px_Testing
lSoapConnect = CREATE SoapConnection
if IsValid(lSoapConnect) then
TRY
rc = lSoapConnect.CreateInstance(px_Testing, 'proxy_testing')
CHOOSE CASE rc
CASE 100
lsReturn = "Invalid proxy name"
CASE 101
lsReturn = "Failed to create proxy"
CASE 0
Proxy_Customer lNewCustomer
lNewCustomer = CREATE Proxy_Customer
lNewCustomer.FirstName = 'Chris'
lNewCustomer.LastName = 'Craft'
lNewCustomer.DOB = 'Getting Older'
Proxy_Children lChildren
lChildren = CREATE Proxy_Children
lChildren.Child[1] = 'Madeline'
lChildren.Child[2] = 'Hayden'
lNewCustomer.Children = lChildren
lsReturn = px_Testing.NewCustomer(lNewCustomer)
CASE ELSE
lsReturn = "Unknown error (" + String(rc) + ")"
END CHOOSE
if rc <> 0 then MessageBox("Invocation Error", lsReturn, Exclamation!)
CATCH (RuntimeError rte)
rc = -1
MessageBox("Runtime Error", rte.text, Exclamation!)
END TRY
end if
Chris Craft -
Assign values to bapi structure dynamically
Hi,
I have to use the BAPI, BAPI_MATERIAL_SAVEDATA to extend the material to different plant specific views. I have to use the structure BAPI_MARC and other structures in order to do this. But the values to be passed to the structure BAPI_MARC are not fixed. These values will be maintained in a custom table against the structure name and field name for a particular plant.
In the program I have to extract the structure name and field name for a corresponding plant from custom table and fill the corresponding value in BAPI structure BAPI_MARC.
Now, internal table in the program is having these details.
How can I fill the bapi structure BAPI_MARC based on this information.
For example, if in custom table, value 0001 is maintained against the field PUR_GROUP, I have to fill the field PUR_GROUP in strcutre BAPI_MARC with 0001.
Hope I am clear in explaining the problem. Please let me know how to aciheve this?
Best Regards,
Kumar.Hi,
I have tried to implement that in a sample program first. Please have a look at the code below.
DATA: BEGIN OF line,
col1 TYPE i,
col2 TYPE i,
col3 TYPE i,
END OF line.
DATA comp(4) TYPE c VALUE 'COL3'.
FIELD-SYMBOLS: <f1> TYPE ANY, <f3> TYPE ANY.
ASSIGN line TO <f1>.
ASSIGN COMPONENT comp OF STRUCTURE <f1> TO <f3>.
IF <f3> IS ASSIGNED.
ENDIF.
I checked in the debugging mode and the value of <f3> in debugging mode is 0, but not line-col3.
Best Regards,
Kumar -
Assign the cost component Structure to Plant/Co Code
hi
can u tell how can i assign the COST COMPONENT STRUCTURE TO THE PLANT AND THE CO CODE...
REGARDSHi,
This is part of Product costing configuration and done with T-code OKTZ. Here, there is a separate diaglog for Assignment of Org units --> cost component structure.
Here, for a particular co. code and all the plants under this Co. code or for only a certain plants and further to a specific costing variant the assignment is done to the cost component structure effective from certain date.
Good Luck!!!
Thanks and Regards,
Bhuvaneswari.S -
The suitable LabVIEW data type correspinding to the array of structure in Visual Basic ActiveX DLL
Hi!
I need to call a VB ActiveX DLL from LabVIEW. When I run my LabVIEW code, I always meet an error as:
Error 1 occurred at Incorrect Function in T06.vi
Possible reasons:
LabVIEW: An input parameter is invalid.
I have read the VB DLL code that defines the data type. It fills data to a structure, then puts this structure to the array, and sends the array of structures to the method.
VB Code:
For I = 1 To 31
Set MyInputData(I) = New EM_nkd_DataPoint
Next I
With MyInputData(1)
.Amplitude = 8.44
.DataPointType = R_HW
.DataSource = MEASURED
.Wav
elength = 409.56
End With
With MyInputData(2)
.Amplitude = 91.60113
.DataPointType = T_SUB
.DataSource = MEASURED
.Wavelength = 409.56
End With
~~~
With MyInputData(31)
.Amplitude = 91.96825
.DataPointType = T_SUB
.DataSource = MEASURED
.Wavelength = 657.43
End With
My problem is that I can’t find a suitable kind of data type in LabVIEW which is corresponding to this case
Attached my LabVIEW code for reference.
Many thsnks.
TX
Attachments:
T07.vi 166 KBHi,
if you have a complete source code including EM_nkd_DataPoint class module, take a look inside in order to see data types for Amplitude, DataPointType, DataSource and Wavelength (probably for Amplitude and Wavelength is SINGLE). If this code is not available, maybe the author mentioned a type for T_SUB and MEASURED even if they are constants. -
Accessing Array of Structures from Coldfusion
I am having a problem accessing an array of structures from
Coldfusion within my flex application. Here is how I make my Array:
(GetRegions is a type Query and Type is a string variable)
<cfset ReturnArray = ArrayNew(1)>
<cfset ReturnArray[1] = StructNew()>
<cfset ReturnArray[1].Query = GetRegions>
<cfset ReturnArray[2] = Type>
Within flex I am trying to access the results in the
following way:
private function dataHandler(event:ResultEvent):void{
Query_Filter = new ArrayCollection(event.result[0].QUERY as
Array);
myString = event.result[1] as String;
Can anybody help me with this. I want a way to return a query
and a string back from coldfusion.
Thanks for the help,
JeffSo now I changed my code to the following in CF:
<cfset Type = "MyString">
<cfset ReturnArray = ArrayNew(1)>
<cfset ReturnArray[1] = StructNew()>
<!--- set up query GetRegions --->
<cfset ReturnArray[1] = GetRegions>
<cfset ReturnArray[2] = Type>
<!--- Return Array --->
<cfreturn ReturnArray>
Now in flex I have the following dataHandler Function:
Alert.show("hello: "+ObjectUtil.toString(event.result[0]));
Query_Filter = new ArrayCollection(event.result as Array);
Now I set up a List box with Query_Filter as the dataprovider
but the results aren't showing correctly. The first item in the
list box is displayed as [object, Object], [object, Object] and the
second item is my String.
Does anybody know how to break up the query to a variable and
the string to its own variable in the dataHandler function.
Thanks for any and all help -
SUPStorage api in SUP 2.1 to store array or structure
Hi,
I am using below code to store key value pair using SUP api for offline storage in workflow apps:
SUPStorage.prototype.setItem(j, airlineId);
Example: var j = 1;
var airlineid = "lufthansa";
This works fine, but I want to store an array or at least a structure (single row) which has multiple items. How can we do that?
I tried passing MBO value data directly, but it gives exception while I try to read:
var mvc = getCurrentMessageValueCollection();
var fData = mvc.getData("flightmbo");
var values = fData.getValue();
var i = 1;
SUPStorage.prototype.setItem(i, values);
This does not give any exception, but when I try to read by using code:
var i = 1;
airlineKey = SUPStorage.prototype.key(i);
values = SUPStorage.prototype.getItem(airlineKey);
var j = 0;
var theItems = values[j];
This gives exception saying "Type Error: Result of expression 'values' [null] is not an object".
Any workarounds to store a structure/array with the same key (such as airline id, text, time, availability).
Thanks,
RohitHave you tried converting the array/structure to a string using JSON (or some similar technique) and storing it that way?
-
ASSIGN COMPONENT x OF STRUCTURE not assigning !
Hello,
the problem is that the component PAKET is not getting assigned to my field symbol (<l_str_applparam> type any) and i don't understand why. The PAKET field is type INT4 and the value is 1111. The importing structure i_str_applparam is also type any.
See coding below:
DATA: l_sel_tab TYPE TABLE OF rsparams,
l_rcl_type TYPE REF TO cl_abap_typedescr,
l_comp_table TYPE abap_component_tab,
l_rcl_struc TYPE REF TO cl_abap_structdescr,
l_tab_fields TYPE abap_compdescr_tab.
m_var_beschreibung = i_var_beschreibung.
DATA l_var_ddic_header TYPE x030l.
l_rcl_struc ?= cl_abap_typedescr=>describe_by_data( i_str_applparam ).
l_var_ddic_header = l_rcl_struc->get_ddic_header( ).
CREATE DATA m_str_applparam TYPE (l_var_ddic_header-tabname).
FIELD-SYMBOLS: <l_str_applparam> TYPE ANY.
GET REFERENCE OF i_str_applparam INTO m_str_applparam.
LOOP AT l_sel_tab INTO l_wrk_sel
WHERE kind = 'P'.
CASE l_wrk_sel-selname.
WHEN 'PA_PAKET'.
IF l_wrk_sel-low IS NOT INITIAL.
ASSIGN COMPONENT 'PAKET' OF STRUCTURE m_str_applparam TO <l_str_applparam>.
CHECK <l_str_applparam> IS ASSIGNED. ?? NOT ASSIGNED ??
<l_str_applparam> = l_wrk_sel-low.
ENDIF.
ENDCASE.
Thank you in advance,
Ioan Constantin.Hello Uwe,
thank you for the first answer. I have another tiny question: i am not allowed to change the values of the import structure and i want to save them in my class, is there a simpler way to save the data besides the loop below ??
DATA: l_var_ddic_header TYPE x030l.
l_rcl_struc ?= cl_abap_typedescr=>describe_by_data( i_str_applparam ).
l_var_ddic_header = l_rcl_struc->get_ddic_header( ).
CREATE DATA m_str_applparam TYPE (l_var_ddic_header-tabname).
FIELD-SYMBOLS: <l_str_applparam> TYPE ANY,
<l_str_m_applparam> TYPE ANY,
<l_var_comp> TYPE ANY,
<l_var_m_comp> TYPE ANY.
ASSIGN i_str_applparam to <l_str_applparam>.
ASSIGN m_str_applparam->* TO <l_str_m_applparam>. "m_str_applparam is a class attribute
DATA l_wrk_rcl_struc TYPE abap_compdescr.
LOOP AT l_rcl_struc->components INTO l_wrk_rcl_struc.
ASSIGN COMPONENT l_wrk_rcl_struc-name OF STRUCTURE <l_str_applparam> TO <l_var_comp>.
ASSIGN COMPONENT l_wrk_rcl_struc-name OF STRUCTURE <l_str_m_applparam> TO <l_var_m_comp>.
<l_var_m_comp> = <l_var_comp>.
ENDLOOP.
Regards,
Ioan. -
Passing an array of structures to an Oracle stored procedure (CFMX)
I'm looking to write a Oracle stored procedure where I would pass in an array of structures and loop over each iteration to insert the bits and pieces within the structures to the DB.,
I haven't written this type of procedure / package before. I am planning to do an sp / package similar to what is sketched out in the second reply to this thread: http://forums.oracle.com/forums/thread.jspa?threadID=1078772
Assuming I do, how can I call the procedure from ColdFusion (I'm using MX) and pass in my array? As far as I can see, none of the CF_SQL_Types make sense.Let me know if you make any progress. I'm fighting the same battle. What I've done so far is to convert my array of struct into a delimited CLOB that looks like this:
prop1;prop2;prop3|prop1;prop2;prop3|prop1;prop2;prop3|prop1;prop2;prop3|
Then I wrote a stored proc to suck it up using a pipelined function. It's not to bad but parsing the CLOB on the ORACLE side is somewhat time consuming.
I've also converted the array to XML and used dbms_xmlstore to convert but, on large arrays, it is very slow and the CLOB gets huge fast.
I was hoping to use the cf_sql_refcursor but I can't figure out how.
Warren -
Array of structures - two ways to approach - which is better?
Folks - I've been trying to create an array of structures,
but I bumped into problem that lead me to an example that is
completely different. I'm trying to figure out which is valid. In
general, it comes down to this:
(1) myStructure
.firstName
vs
(2) myStructure.firstName
The problem with the first is that I can't find a way to
discover the size of the array, which leads me to suspect this is
not a valid method. The problem with the second is that you must
redefine the structure for EACH array element, which seems like it
would add a lot of overhead.
Any advice? Sample code attached.
Thanks!
************* Sample (1) **************
<CFSET sCust=StructNew()>
<CFSET vCustCount = #rsMailAuth.recordcount#>
<CFSET i = 0>
<CFOUTPUT QUERY="rsMailAuth">
<CFSET i = i+1>
<CFSET sCust.userId
= #rsMailAuth.userId#>
<CFSET sCust.validEmailSource =
#rsMailAuth.validTcEmails#>
<CFSET sCust.authKeyword
= #rsMailAuth.tcEmailKeyword#>
<CFSET sCust.authKeywordLoc =
#rsMailAuth.tcEmailKeywordLoc#>
</CFOUTPUT>
************* Sample (2) **************
<cfset strTest = arrayNew(1) >
<cfset strTest[1] = structNew() >
<CFLOOP INDEX = "i" FROM="1" TO="5" >
<cfset strTest
= structNew() >
<cfset strTest.id = i>
<cfset strTest
.name = "[email protected]">
</CFLOOP>
<cfoutput>#arrayLen(strTest)#</cfoutput>Sorry - simple english...
I am collecting a series of emails from a pop email server.
As I parse these into the individual parts (subject, body, from,
etc) I want to stuff them into a structure. each email would be a
new index. so, the 2nd email 'from' info would go into
myStructure.from[2] or myStructure[2].from.
I know there are lots of ways around this, I just have a
natural predisposition to use structures when possible as it makes
it easier for me to keep track of things and makes it easier to
follow the code.
I can make either of these work, I'm just not sure if they
are valid in the world of coldfusion8.
Maybe you are looking for
-
How do you setup the ipad !!!
-
How to load DTD structure runtime in Mapping
Dear All, I have Interface, used DTD as external definition and did mapping. Customer said, there is one tag, that Tag name will be changed dynamically based on Ship type. How to handle this in XI Mapping to not to fail mapping Regards
-
Work email not syncing with device as it should
Hello all My work email account, configured as IMAP account on my passport, is not syncing as it should. for example. if my outlook on my PC performs send/receive and mails are synced there, my device doesn't receive any emails. and if PC is off, or
-
Can give me the details how to release the transport request to the qa
can give me the details how to release the transport request to the quality server pr production server thanks
-
Top 25 Played Playlist updates on computer, but stays the same on iPhone
Hey guys, I'm hoping someone else can help me. My iTunes Top 25 playlist updates just fine on my iMac, but not on any of my iPhones/iPods. It has stayed the same constantly for about a year now, and I'm wondering if it's a file in the iTunes library