Advertisement

03.28.2008 at 01:41AM PDT, ID: 23276651 | Points: 500
[x]
Attachment Details

Pass pointer variable from Python to C method

Tags: Python, C
I am new to Python.
I need to use below Framemaker method (written in C) within Python code.

F_ApiOpen(compName, &script, &returnp);

How do I pass "&returnp" value to above method from Python code?
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: srinivasysr2003
Question Asked On: 03.28.2008
Participating Experts: 2
Points: 500
Views: 0
Translate:
Loading Advertisement...
03.28.2008 at 01:44AM PDT, ID: 21228753

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.29.2008 at 11:42PM PDT, ID: 21239838

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.02.2008 at 09:58AM PDT, ID: 21265019

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.02.2008 at 04:31PM PDT, ID: 21268510

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.02.2008 at 04:50PM PDT, ID: 21268620

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.02.2008 at 05:02PM PDT, ID: 21268680

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.02.2008 at 06:29PM PDT, ID: 21269106

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.03.2008 at 12:22AM PDT, ID: 21270272

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.03.2008 at 03:00AM PDT, ID: 21270928

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.03.2008 at 08:44AM PDT, ID: 21273812

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.13.2008 at 06:57PM PDT, ID: 21347077

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.13.2008 at 11:14PM PDT, ID: 21347831

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.01.2008 at 05:24PM PDT, ID: 21912605

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.28.2008 at 01:44AM PDT, ID: 21228753
Object type of "returnp" is "F_PropValT"

I want to use something like below.

F_PropValT <variable>*

Please provide the correct statement.
 
03.29.2008 at 11:42PM PDT, ID: 21239838
srinivasysr2003,

We have sent a message to some of our more experienced Experts asking them to review your question, and will check back again to see if you are getting the help you need. I have also added zones to your question.

Thank you for using Experts Exchange,

Netminder
Site Admin
http://www.experts-exchange.com/Q_23278563.html
 
04.02.2008 at 09:58AM PDT, ID: 21265019
Hi,

Can any one provide the solution to my problem?

If the question is not clear, please let me know so that I can pin-point the issue.

Thanks,
Srinivas
 
04.02.2008 at 04:31PM PDT, ID: 21268510
srinivasysr2003
 
Another message has been sent to some of our more experienced Experts asking them to review your question.
 
I will check back again to see if you are getting the help you need.
 
Thank you for using Experts Exchange,
 
Vee_Mod
Experts Exchange Moderator
Link to CS-G post:
http://www.experts-exchange.com/Q_23278563.html
 
04.02.2008 at 04:50PM PDT, ID: 21268620

Rank: Master

Is this Adobe Framemaker? If so I am at a loss, as the Adobe web site for Framemaker says NOTHING about automating it.

Please tell us:

Which operating system are you running

How are Framemaker methods invoked from outside itself. Via COM, as a dll, or what?
 
04.02.2008 at 05:02PM PDT, ID: 21268680

Rank: Master

FWIW I suggest providing a lot more information in the original question.
 
04.02.2008 at 06:29PM PDT, ID: 21269106
Hi ramrom,

I have below sample C program which was written in Framemaker Development Kit (FDK).
I want to run Python script from Windows.

In this I am referring to "VoidT SaveAsPdf()" method having below lines.  I want to call them from Python scripting language.

F_PropValsT  params, *returnParams = NULL;

params = F_ApiGetSaveDefaultParams();
i = F_ApiGetPropIndex(&params, FS_FileType);
params.val[i].propVal.u.ival = FV_SaveFmtPdf;
i = F_ApiGetPropIndex(&params, FS_SaveAsModeName);
params.val[i].propVal.u.ival = FV_SaveAsNameAskUser;
i = F_ApiGetPropIndex(&params, FS_SaveMode);
params.val[i].propVal.u.ival = FV_ModeSaveAs;

saveId = F_ApiSave(bookId, "", &params, &returnParams);

Please let us know, if you need any further information.

Note:-
I am able to use below statement in Python and producing PDF file perfectly fine (prompt for user to enter PDF file name) after making the above lines to COMMENTED.
F_ApiSimpleSave(docId, name, True);
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
#include "fapi.h"
#include "fdetypes.h"
#include "fmemory.h"
#include "futils.h"
#include "fstrings.h"
 
#define SVPDF 1
#define SVHTML 2
 
/* Function protocols */
VoidT SaveAsPdf(VoidT);
VoidT SaveAsHtml(VoidT);
VoidT openBookFiles(F_ObjHandleT bookId);
 
 
VoidT F_ApiInitialize(IntT init)
{
	F_ObjHandleT menuBarId, menuId;
 
	switch(init)
	{
	case FA_Init_First:
	menuBarId = F_ApiGetNamedObject(FV_SessionId, FO_Menu, "!BookMainMenu");
	menuId = F_ApiDefineAndAddMenu(menuBarId, "APIMenu", "API");
	F_ApiDefineAndAddCommand(SVPDF, menuId, "SvPdfCmd", "Save As PDF", "");
	F_ApiDefineAndAddCommand(SVHTML, menuId, "SvHtmlCmd", "Save As HTML", "");
	F_ApiBailOut();
	break;
	}
}
 
VoidT F_ApiCommand(IntT command)
{
	switch(command)
	{
		case SVPDF:
			SaveAsPdf();
			break;
		
		case SVHTML:
			SaveAsHtml();
			break;
		
		default:
			break;
	}
}
 
VoidT SaveAsPdf()
{
	F_PropValsT params, *returnParams = NULL;
	F_ObjHandleT docId, pgfId, saveId, bookId;
	IntT i = 0;
	StringT name = NULL;
 
	F_FdeInit();
	bookId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveBook);
 
	/* Open all files */ 
	openBookFiles(bookId);
 
	/* Get docId in order to set Acrobat Bookmark levels */
	docId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_FirstOpenDoc);
	if(!docId)
    {
	F_ApiAlert("Couldn't open first component.", FF_ALERT_CONTINUE_NOTE);
	return;
    }
 
	/* Sets "Body" to the highest Acrobat Bookmark level. */
	   
	pgfId = F_ApiGetNamedObject(docId, FO_PgfFmt, "Body");
	F_ApiSetInt(docId, pgfId, FP_AcrobatLevel, 1);
	F_ApiSimpleSave(docId, name, False);
 
	/* Sets the save parameters so as to save as PDF and allow user to name file.*/
	params = F_ApiGetSaveDefaultParams();
	i = F_ApiGetPropIndex(&params, FS_FileType);
	params.val[i].propVal.u.ival = FV_SaveFmtPdf;
	i = F_ApiGetPropIndex(&params, FS_SaveAsModeName);
	params.val[i].propVal.u.ival = FV_SaveAsNameAskUser;
	i = F_ApiGetPropIndex(&params, FS_SaveMode);
	params.val[i].propVal.u.ival = FV_ModeSaveAs;
 
	/* Saves the book and all its components to one PDF file */
	saveId = F_ApiSave(bookId, "", &params, &returnParams);
	/* Close the open files.*/
	while (docId)
	{
		F_ApiClose(docId, FF_CLOSE_MODIFIED);
		docId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_NextOpenDocInSession);
	}
 
	F_ApiDeallocatePropVals(&params);
	F_ApiDeallocatePropVals(returnParams);
}
 
VoidT SaveAsHtml()
{
	F_PropValsT params, *returnParams = NULL;
	F_ObjHandleT saveId, bookId;
	IntT i = 0;
	
	F_FdeInit();
	
	/* Gets the active book (bookId) */
	bookId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveBook);
	
	/* Sets save parameters */
	params = F_ApiGetSaveDefaultParams();
	i = F_ApiGetPropIndex(&params, FS_FileType);
	params.val[i].propVal.u.ival = FV_SaveFmtFilter;
	i = F_ApiGetPropIndex(&params, FS_SaveFileTypeHint);
	params.val[i].propVal.u.sval = F_StrCopyString("0001ADBEHTML");
	i = F_ApiGetPropIndex(&params, FS_SaveAsModeName);
	params.val[i].propVal.u.ival = FV_SaveAsNameAskUser;
	i = F_ApiGetPropIndex(&params, FS_SaveMode);
	params.val[i].propVal.u.ival = FV_ModeSaveAs;
 
	/* Saves the book and all its components to a single HTML file.*/
	saveId = F_ApiSave(bookId, "", &params, &returnParams);
	F_ApiDeallocatePropVals(&params);
	F_ApiDeallocatePropVals(returnParams);
}
 
VoidT openBookFiles(F_ObjHandleT bookId)
{
	IntT i = 0; 
	F_PropValsT script, *returnp = NULL;
	F_ObjHandleT compId; 
	F_ObjHandleT docId; 
	StringT compName = NULL;
 
 
	/* create open script which minimizes user response*/
	script = F_ApiGetOpenDefaultParams();
	i = F_ApiGetPropIndex(&script, FS_MakeVisible);
	script.val[i].propVal.u.ival = False;
	i = F_ApiGetPropIndex(&script, FS_RefFileNotFound);
	script.val[i].propVal.u.ival = FV_AllowAllRefFilesUnFindable;
	i = F_ApiGetPropIndex(&script, FS_FileIsOldVersion);
	script.val[i].propVal.u.ival = FV_DoOK;
	i = F_ApiGetPropIndex(&script, FS_FontChangedMetric);
	script.val[i].propVal.u.ival = FV_DoOK;
	i = F_ApiGetPropIndex(&script, FS_FontNotFoundInCatalog);
	script.val[i].propVal.u.ival = FV_DoOK;
	i = F_ApiGetPropIndex(&script, FS_FontNotFoundInDoc);
	script.val[i].propVal.u.ival = FV_DoOK;
	i = F_ApiGetPropIndex(&script, FS_LanguageNotAvailable);
	script.val[i].propVal.u.ival = FV_DoOK;
	i = F_ApiGetPropIndex(&script, FS_LockCantBeReset);
	script.val[i].propVal.u.ival = FV_DoOK;
	i = F_ApiGetPropIndex(&script, FS_UpdateTextReferences);
	script.val[i].propVal.u.ival = FV_DoNo;
	i = F_ApiGetPropIndex(&script, FS_UpdateXRefs);
	script.val[i].propVal.u.ival = FV_DoNo;
	i = F_ApiGetPropIndex(&script, FS_UseAutoSaveFile);
	script.val[i].propVal.u.ival = FV_DoNo;
	i = F_ApiGetPropIndex(&script, FS_UseRecoverFile);
	script.val[i].propVal.u.ival = FV_DoNo;
	i = F_ApiGetPropIndex(&script, FS_AlertUserAboutFailure);
	script.val[i].propVal.u.ival = False;
	i = F_ApiGetPropIndex(&script, FS_BeefyDoc);
	script.val[i].propVal.u.ival = FV_DoOK;
	i = F_ApiGetPropIndex(&script, FS_FileIsInUse);
	script.val[i].propVal.u.ival = FV_OpenViewOnly;
	i = F_ApiGetPropIndex(&script, FS_FileIsStructured);
	script.val[i].propVal.u.ival = FV_OpenViewOnly;
	i = F_ApiGetPropIndex(&script, FS_OpenFileNotWritable);
	script.val[i].propVal.u.ival = FV_DoOK;
 
 
	/* get all components in the active book and open using script */
	compId = F_ApiGetId(FV_SessionId, bookId, FP_FirstComponentInBook);
	i = 0;
	while(compId){
		/* get component name */
		compName = F_ApiGetString(bookId, compId, FP_Name);
		/* open the document with the component name */
		docId = F_ApiOpen(compName, &script, &returnp);
 
		/* check outcome of open for FV_ReferencedFilesWerentFound */
		if(F_ApiCheckStatus(returnp, FV_ReferencedFilesWerentFound)){
			F_Printf(NULL, (StringT) "%s contains graphic files that could not be found.\n", compName);
 
		}
		/* check status of FV_UnresolvedTextInsets */
		if(F_ApiCheckStatus(returnp, FV_UnresolvedTextInsets)){
			F_Printf(NULL, (StringT) "%s contains imported text files that could not be found.\n", compName);
 
		}
		/* deallocate propVals */
		F_ApiPrintSaveStatus(returnp);
		F_ApiDeallocatePropVals(returnp);
		if(compName != NULL)
			F_Free(compName);
		/* get next component in book */
		compId = F_ApiGetId(bookId, compId, FP_NextComponentInBook);
		i++;
	}
	F_ApiDeallocatePropVals(&script);
 
}
Open in New Window
 
04.03.2008 at 12:22AM PDT, ID: 21270272
i recommend you use swig library: http://www.swig.org/tutorial.html

hth,
A.
 
04.03.2008 at 03:00AM PDT, ID: 21270928
Hi Agarici,

Someone has already developed using SWIG library and we have the .pyd and few .py code also.  There is no documentation around it and no one knows, how to pass these values in Python now.

1) I have tried to print the values of "params" params = testfdk.F_ApiGetSaveDefaultParams(); and got the below lines.

<testfdk.F_PropValsTPtr; proxy of C F_PropValsT instance at _b80fbd00_p_F_PropValsT>

2) Index value is "0" for below statement.
i = testfdk.F_ApiGetPropIndex(params, testfapidefs.FS_FileType)

3) params.val[i].propVal.u.ival = testfdk.FV_SaveFmtPdf;

Getting below error when I want to set the value in the above statement to the same Index.
Traceback (most recent call last):
  File "testscript.py", line 23, in ?
  File "<string>", line 2, in ?
  File "saveaspdf.py", line 91, in main
    params.val[i].propVal.u.ival = testfapidefs.FV_SaveFmtPdf
TypeError: unindexable object

Please let us know, how do I need to assign the value in the #3 successfully?
 
04.03.2008 at 08:44AM PDT, ID: 21273812

Rank: Master

I moved the C program to the code snippet to make it more readable.
 
04.13.2008 at 06:57PM PDT, ID: 21347077

Rank: Master

Try this? I'm guessing, since params seems indexible:

params[i].val.propVal.u.ival = testfapidefs.FV_SaveFmtPdf
 
04.13.2008 at 11:14PM PDT, ID: 21347831
Hi Ramrom,

Still I get same error.

Traceback (most recent call last):
  File "testscript.py", line 23, in ?
  File "<string>", line 2, in ?
  File "saveaspdf.py", line 77, in main
    params[i].val.propVal.u.ival = testfapidefs.FV_SaveFmtPdf
TypeError: unindexable object
 
07.01.2008 at 05:24PM PDT, ID: 21912605
Please close the case as there is no answer to my question.
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628