ACS19@UHUPVM1.BITNET (07/02/86)
Question: How can one get the address of te_ptext, te_ptmplt, etc. of a loaded resource? Using the rsrc_gaddr call seems to be paradoxical. It seems that to find the address, one must supply the index number in the resource file. Problems arise when one discovers that one cannot assign an index value to anything but a tree or an object in the RCS. I have tried using (char *)(LLGET(LLGET(OB_SPEC(OBJ)))) to get: 1) the pointer to the ob_spec (OB_SPEC(OBJ)) 2) the tedinfo pointed to by ob_spec LLGET(OB_SPEC(OBJ)) 3) the te_ptext pointer pointed by tedinfo LLGET(LLGET(OB_SPEC(OBJ))) 4) the string pointed to by te_ptext (char *)(LLGET(LLGET(OB_SPEC(OBJ))) It would seem to be a waste of memory to have to allocate an array for each string I wish to copy to. Why not use the space in the resource file? Also, if I choose to point my tedinfo with LLSET(OB_SPEC(OBJ)), this would require that I allocate many tedinfo structures, which is a BIGGER waste. What I desire is to take the persons input from a dialog editable field, and copy it to another editable field. All I have to do is find out the address of the te_ptext and I have it made. The rsrc_gaddr call seems cryptic in trying to get anything but a tree or object. If you can help, thanks. I know some hang-abouter from Megamax is out there, so if you can help.... PLEASE DO. Thanx, Michael Vederman p.s. If I used the C code of the resource, I would have no problem, but...
ACS19@UHUPVM1.BITNET (07/02/86)
AHA... Going over the file stcreate.c seems to have shed some light... the te_ptext, ob_spec, and associated fields are all relative indexes from the beginning of the resource file. It would seem that adding the index to the address of the resource might get the right spot. I have yet to try... That would explain why the LLGET would not work... Still, any help would be appreciated. Thanx, Mike
wardlaw@hope.UUCP (Johnie Wardlaw) (07/02/86)
> Question: > How can one get the address of te_ptext, te_ptmplt, etc. of a loaded resource? > Using the rsrc_gaddr call seems to be paradoxical. > It seems that to find the address, one must supply the index number in the > resource file. Problems arise when one discovers that one cannot assign > an index value to anything but a tree or an object in the RCS. Here is how I would copy from one text field to another using MegaMax C (which I use every day, by the way!): DIALOG *d1,*d2; int dx,dy,dw,dh,dret; rsrc_gaddr(0,D1_INDEX,&d1); form_center(d1,&dx,&dy,&dw,&dh); form_dial(FMD_BEGIN,dx,dy,dw,dh,dx,dy,dw,dh); objc_draw(d1,0,MAX1_INDEX,dx,dy,dw,dy); dret = form_do(d1,D1TEXT_INDEX); form_dial(FMD_FINISH,dx,dy,dw,dh,dx,dy,dw,dh); rsrc_gaddr(0,D2_INDEX,&d1); strcpy(((TEDINFO *) d2[D2TEXT_INDEX].ob_spec)->te_ptext, ((TEDINFO *) d1[D1TEXT_INDEX].ob_spec)->te_ptext); form_center(d2,&dx,&dy,&dw,&dh); form_dial(FMD_BEGIN,dx,dy,dw,dh,dx,dy,dw,dh); objc_draw(d2,0,MAX2_INDEX,dx,dy,dw,dy); dret = form_do(d2,D2TEXT_INDEX); form_dial(FMD_FINISH,dx,dy,dw,dh,dx,dy,dw,dh); You can get fancy and do the "growbox" stuff, but this is all that I do. I haven't actually tried this code, so it may have a bug or two...I typed it in from the top of my head (I was working on dialog stuff last night so it was still floating around in there!) The only problem that I forsee is that the second dialog (destination string of copy) should be initialized in the MMRCP program to be spaces to allocate the memory needed for the "strcpy". Let me know how it goes...I would be interested in any tips on how to get the EDIT stuff working...I can only make it work correctly when I initialize PTEXT in MMRCP with a default string or spaces. Maybe I have to allocate more memory for it and change the te_ptxtlen (???) value? Good luck! -- Johnie /*********************************************************\ ** Johnie Wardlaw, Undergraduate: Computer Science ** ** University of California, Riverside ** ** {ucbvax!ucdavis, ihnp4!ucla-cs} ucrmath!hope!wardlaw ** ** ** ** "If that was foreplay, I'm a dead man!" ** ** -- Cocoon (alien sex scene) ** \*********************************************************/
dclemans@mntgfx.UUCP (07/07/86)
One way to get the address of text fields in a loaded resource is as follows: Assume that "BOX" is the name you gave to the dialog box that contains the editable field. Assume further that "FIELD" is the name of the editable field. Then with the following code fragment: #include ".h file created by resource construction program" OBJECT *obj; TEDINFO *ted; rsrc_gaddr(R_TREE,BOX,&obj); ted = (TEDINFO *)obj[FIELD].ob_spec; the expression "ted->te_ptext" gives you the address of the te_ptext field, etc. dgc