<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Dear Davide</div><div><br></div><div>You need to create a plug-in to import binary files. The sources of the importers that come with pro Fit are not public, so we cannot share them. But you can start from the example plug-in that comes with pro Fit (Example Files/Programming 7 - plug-ins/Sources/C/Example Plugin).</div><div><br></div><div>You proceed basically as follows:</div><div><br></div><div>1. Duplicate the Example Plugin directory. Rename the directory as it suits you (e.g. MyImporter)</div><div><br></div><div>2. Modify MyImporter:</div><div><br></div><div>2a) In main.c, change the function SetUp to return isProgram in *moduleKind and to return a good name for your plug-in</div><div><br></div><div>2b) In main.c, change the function Run to import the file. It could e.g. look like this:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>Boolean<span class="Apple-tab-span" style="white-space:pre">                                </span>mustCloseFile=false;<span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #1a521c">// true if we have opened file</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(26, 82, 28); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="color: #760f50">short</span><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                                </span>refNum;<span class="Apple-tab-span" style="white-space:pre">                        </span></span>// file reference number</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>FSRef<span class="Apple-tab-span" style="white-space:pre">                                </span>fileRef;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>ByteCount<span class="Apple-tab-span" style="white-space:pre">                        </span>size;<br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-style-span" style="color: rgb(26, 82, 28); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span>HFSUniStr255 <span class="Apple-tab-span" style="white-space:pre">        </span>dataForkName;<span class="Apple-tab-span" style="white-space:pre">        </span></span>// the name of the data fork, to be used when opening a file with FSRefOpenFork</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; ">// let the user choose the file</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #760f50">if</span> (!MyGetFileRef(&amp;fileRef, '****', '****'))</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(26, 82, 28); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                </span></span><span style="color: #760f50">goto</span><span style="color: #000000"> done; </span>// if user hit cancel or some other evil thing happened.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">// open the file</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>FSGetDataForkName(&amp;dataForkName);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>if (FSOpenFork(&amp;fileRef, dataForkName.length, dataForkName.unicode, fsRdPerm, &amp;refNum) != noErr) goto done;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>mustCloseFile = true;</div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;">// create a new data window, e.g.<span class="Apple-tab-span" style="white-space:pre"></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>BeginCommand(<span style="color: #891315">"\pNewDataWindow"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>AddDoubleParam(<span style="color: #891315">"\pnrRows"</span>, 1000);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>AddDoubleParam(<span style="color: rgb(137, 19, 21); ">"\pnrCols"</span>, 3);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>EndCommand();</div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;">// read your file, e.g. an 8 byte double and write it to cell 1/1 of the data window</span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><span class="Apple-tab-span" style="white-space:pre">        </span>double<span class="Apple-tab-span" style="white-space:pre">        </span>d;<br></span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><span class="Apple-tab-span" style="white-space:pre">        </span>if (FSReadFork(refNum, fsAtMark, <span style="color: #0000ff">0</span>, 8, &amp;d, &amp;size) != noErr) goto done;</span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><span class="Apple-tab-span" style="white-space:pre">        </span>SetData(1, 1, d);</span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">done:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #760f50">if</span> (mustCloseFile) FSCloseFork(refNum);</div></div><br><div><div>The function&nbsp;<span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; ">MyGetFileRef</span>&nbsp;is defined in the file ModuleUtilities.c, which can be found at Example Files/Programming 7 - plug-ins/Utilities/C/. You need to at that and its header file to the project.</div><div><br></div><div>Note: I have not tried to compile the above, so it may need some minor corrections. But I hope that this will help you to get started.</div><div><br></div><div>Regards</div><div><br></div><div>Kurt</div><div><br></div><div>On 30.10.2008, at 05:56, Davide Guarisco wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hello,<br><span class="Apple-tab-span" style="white-space:pre">        </span>I need to read data files in binary format. How can I do this in pro Fit? Do I need to write a plug-in or is there some programming functions that I can use?<br><br>I looked at the pro Fit plug-ins>Plug-Ins written in C>Data import folder, and there are some plug-ins that do import binary files. The problem is that there is no source code for these plug-ins.<br><br>Thanks,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Davide<br>--<br>Davide Guarisco_______________________________________________<br>proFit-list mailing list<br><a href="mailto:proFit-list@quantum-soft.com">proFit-list@quantum-soft.com</a><br>http://quantum-soft.com/mailman/listinfo/profit-list_quantum-soft.com<br></div></blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><div>Best regards</div><div><br class="khtml-block-placeholder"></div><div>Kurt Sutter</div><div>QuantumSoft</div></div><br class="Apple-interchange-newline"></span> </div><br></body></html>