Krzysiek pisze:
> Hello
>
> I have a problem. I'm trying to add attribute to element but I haven't
> still done it. So I decided to write a program to testing but it doesn't
> work too. What I do wrong ? Why function mdlLinkage_appendToElement
> cannot add attribute to element ?
>
> test.mc:
>
> #include <mdl.h>
> #include <mselems.h>
> #include <stdio.h>
> #include <string.h>
>
> #include "test.h"
>
> #include <mselemen.fdf>
> #include <mscurrtr.fdf>
> #include <mssystem.fdf>
> #include <mslinkge.fdf>
> #include <msdialog.fdf>
>
> #define TESTID 999
>
> #define ID_GRAF 1
>
> int main(int argc, char *argv[])
> {
> DPoint3d p[2] = {{0.0,0.0,0.0},
> {50.0,50.0,0.0}};
> MSElement el;
> LinkageHeader header;
> Attr att;
> AttrRecv copy;
> UInt fPos;
> char napis[200];
>
>
> memset(&header, 0, sizeof(LinkageHeader));
> header.info =0;
> header.remote =0;
> header.modified =0;
> header.user = 1;
> header.primaryID = TESTID;
> att.id = 500;
>
> mdlCurrTrans_begin ();
> mdlCurrTrans_masterUnitsIdentity(TRUE);
>
> if (mdlLine_create(&el, NULL, p) != SUCCESS)
> {
> printf("nie udało się utworzyć elementu!\n");
> return 1;
> }
> mdlCurrTrans_end ();
>
> mdlElement_display(&el, NORMALDRAW);
>
>
> if(mdlLinkage_appendToElement(&el, &header, &att, ID_GRAF, NULL) !=
> SUCCESS)
> {
> mdlDialog_openInfoBox("Nie podpięto atrubutu");
> mdlSystem_unloadMdlProgram("userlink");
> return 1;
> }
> else
> mdlDialog_openInfoBox("Podpieto atrybut");
>
> //mdlElement_rewrite(&el, NULL, fPos);
> fPos = mdlElement_add(&el);
> if (fPos<= 0L)
> {
> printf("nie udało się dodać elementu do pliku!\n");
> mdlSystem_unloadMdlProgram("userlink");
> return 1;
> }
>
> if (mdlLinkage_extractFromElement( ©, &el, TESTID, ID_GRAF,NULL,
> NULL, NULL) != SUCCESS)
> {
> mdlDialog_openInfoBox("Nie zczytano atrybutu");
> mdlSystem_unloadMdlProgram("userlink");
> return 1;
> }
> else
> {
> sprintf(napis, "Atrybut ma wartość = %d", copy.id);
> mdlDialog_openInfoBox(napis);
> }
> mdlSystem_unloadMdlProgram("userlink");
> return 0; /*meaningless int value returned by main */
> }
>
>
> test.h:
>
> #include <mselems.h>
>
> typedef struct attr {
> int id;
> } Attr;
>
> typedef struct attr_Recv {
> LinkageHeader header;
> int id;
> } AttrRecv;
>
> test.mt
>
> #include "test.h"
>
> createDataDef (attr, TEST);
>
>
>
> I hope you can help me.
> Thanks
> Krzysztof
When I got on top lines:
RscFileHandle rscFH;
mdlResource_openFile (&rscFH, NULL, 0);
I can append attribute but I still can't extract attribute from element.
I get info that the stored value is equal 0.
What could by wrong ?
Krzysztof


|