comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » IDL_FileOpen problem?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
IDL_FileOpen problem? [message #20344] Tue, 13 June 2000 00:00 Go to next message
Nando Iavarone is currently offline  Nando Iavarone
Messages: 48
Registered: December 1998
Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Dear all,
<br>I have some problems reading files using DLM under win platform.
<br>I am using IDL 5.2.1 and VisualC++ compiler.
<p>I wrote a little file called 'foo', using the simple
<p>IDL>&nbsp;data = dindgen(10)
<br>IDL>&nbsp;openW, 1, 'foo'
<br>IDL>&nbsp;writeU, 1, data
<br>IDL>&nbsp;close, 1
<p>After it I need to read them from a c-function in a DLM.
<br>&nbsp;
<br>&nbsp;
<p>- The code&nbsp; below works fine on unix platform (SGI and linux) but
it can't read data if used on WIN 98, NT.
<br>Anyone knows what's happening? A flag problem in the open?
<br>Note that after the IDL_FileOpen the same procedure is repeated using
simple fopen, and all is ok.
<p>- The documentation about the IDL_FileOpen (IDL - External Development
Guide) does not match the prototype definition in the file external.h.
This is for EDG 5.0, 5.1, 5.2,5.3
<br>&nbsp;
<br>&nbsp;
<p>This is the simple testmodule.c of the IDL distribution suitably modified.
This means you already have the makefile (or the win batch) to compile
it.
<br>&nbsp;
<p>Thank you for your help,
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Nando.
<br>&nbsp;
<br>&nbsp;
<p>#include &lt;stdio.h>
<br>#include "export.h"
<p>/* Handy macro */
<br>#define ARRLEN(arr) (sizeof(arr)/sizeof(arr[0]))
<p>/*
<br>&nbsp;* Define message codes and their corresponding printf(3) format
<br>&nbsp;* strings. Note that message codes start at zero and each one
is
<br>&nbsp;* one less that the previous one. Codes must be monotonic and
<br>&nbsp;* contiguous.
<br>&nbsp;*/
<br>static IDL_MSG_DEF msg_arr[] =
<br>{
<br>#define M_TM_INPRO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0
<br>&nbsp; {&nbsp; "M_TM_INPRO",&nbsp;&nbsp; "%NThis is from a loadable
module procedure." },
<br>#define M_TM_INFUN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-1
<br>&nbsp; {&nbsp; "M_TM_INFUN",&nbsp;&nbsp; "%NThis is from a loadable
module function." },
<br>};
<br>&nbsp;
<br>&nbsp;
<p>/*
<br>&nbsp;* The load function fills in this message block handle with the
<br>&nbsp;* opaque handle to the message block used for this module. The
other
<br>&nbsp;* routines can then use it to throw errors from this block.
<br>&nbsp;*/
<br>static IDL_MSG_BLOCK msg_block;
<br>&nbsp;
<br>&nbsp;
<p>/* Implementation of the TESTPRO IDL procedure */
<p>static void testpro(int argc, IDL_VPTR *argv)
<br>{
<p>&nbsp;&nbsp;&nbsp; FILE *fPtr=NULL;
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; int err = 0;
<br>&nbsp;&nbsp;&nbsp; int i = 0;
<br>&nbsp;&nbsp;&nbsp; int lun=10;
<p>&nbsp;&nbsp;&nbsp; char&nbsp;&nbsp; tmpstr[100];
<br>&nbsp;&nbsp;&nbsp; char&nbsp;&nbsp; chararr[100];
<p>&nbsp;&nbsp;&nbsp; double dblarr[10];
<br>&nbsp;&nbsp;&nbsp; double buf[10];
<p>&nbsp;&nbsp;&nbsp; IDL_VPTR idlErr;
<br>&nbsp;&nbsp;&nbsp; IDL_VPTR ArgV[2];
<br>&nbsp;&nbsp;&nbsp; IDL_VPTR Lun;
<br>&nbsp;&nbsp;&nbsp; IDL_VPTR tmp;
<p>&nbsp;&nbsp;&nbsp; IDL_FILE_STAT FileStat;
<p>&nbsp;&nbsp;&nbsp; IDL_LONG dim[IDL_MAX_ARRAY_DIM];
<br>&nbsp;
<p>&nbsp;
<br>&nbsp;&nbsp;&nbsp; tmp = IDL_StrToSTRING("starting testpro\n");
<br>&nbsp;&nbsp;&nbsp; IDL_Print(1,&amp;tmp,NULL);
<p>&nbsp;
<br>&nbsp;&nbsp;&nbsp; Lun&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;
= IDL_Gettmp();
<br>&nbsp;&nbsp;&nbsp; Lun->type&nbsp;&nbsp;&nbsp; = IDL_TYP_LONG;
<br>&nbsp;&nbsp;&nbsp; Lun->value.l = lun;
<br>&nbsp;&nbsp;&nbsp; ArgV[0] = Lun;
<br>&nbsp;&nbsp;&nbsp; ArgV[1] = IDL_StrToSTRING("foo");
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; /* read */
<br>&nbsp;&nbsp;&nbsp; IDL_Print(1, &amp;ArgV[1], NULL);
<br>&nbsp;&nbsp;&nbsp; err = IDL_FileOpen(2, ArgV, NULL, IDL_OPEN_R, IDL_F_DOS_BINARY,
TRUE, 0);
<br>&nbsp;&nbsp;&nbsp; if (err == FALSE)
<br>&nbsp;&nbsp;&nbsp; {
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; tmp = IDL_StrToSTRING("can't
open......\n");
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IDL_Print(1,&amp;tmp,NULL);
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return ;
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; IDL_FileStat(lun, &amp;FileStat);
<br>&nbsp;&nbsp;&nbsp; err = fread(dblarr, 10*sizeof(double), 1, FileStat.fptr);
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp;&nbsp; if (err != 1)
<br>&nbsp;&nbsp;&nbsp; {
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; tmp = IDL_StrToSTRING("can't
read......\n");
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IDL_Print(1,&amp;tmp,NULL);
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; /* return; */
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; tmp = IDL_StrToSTRING("after fread\n");
<br>&nbsp;&nbsp;&nbsp; IDL_Print(1,&amp;tmp,NULL);
<br>&nbsp;&nbsp;&nbsp; IDL_FileClose(1, &amp;ArgV[0], NULL);
<p>&nbsp;&nbsp;&nbsp; dim[0]=10;
<br>&nbsp;&nbsp;&nbsp; tmp = IDL_ImportArray(1, dim, IDL_TYP_DOUBLE, (UCHAR*)dblarr,
NULL, NULL);
<br>&nbsp;&nbsp;&nbsp; IDL_Print(1, &amp;tmp, NULL);
<br>&nbsp;
<p>&nbsp;
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; /* fopen */
<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if( (fPtr&nbsp; = fopen(
"foo", "rb" )) == NULL )
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
tmp = IDL_StrToSTRING("can't fopen ......\n");
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
IDL_Print(1,&amp;tmp,NULL);
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
err = fread(dblarr, 10*sizeof(double), 1, fPtr);
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
if (err != 1)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
{
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tmp = IDL_StrToSTRING("can't read......\n");
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
IDL_Print(1,&amp;tmp,NULL);
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
/* return; */
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
}
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
tmp = IDL_ImportArray(1, dim, IDL_TYP_DOUBLE, (UCHAR*)dblarr, NULL, NULL);
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
IDL_Print(1, &amp;tmp, NULL);
<p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
fclose(fPtr);
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }
<br>&nbsp;
<p>&nbsp;&nbsp;&nbsp; /* cleanup */
<br>&nbsp;&nbsp;&nbsp; IDL_Deltmp(Lun);
<br>&nbsp;&nbsp;&nbsp; IDL_Deltmp(tmp);
<br>}
<br>&nbsp;
<br>&nbsp;
<p>/* Implementation of the TESTFUN IDL function */
<br>static IDL_VPTR testfun(int argc, IDL_VPTR *argv)
<br>{
<p>&nbsp; IDL_MessageFromBlock(msg_block, M_TM_INFUN, IDL_MSG_RET);
<br>&nbsp; return IDL_StrToSTRING("TESTFUN");
<br>}
<br>&nbsp;
<br>&nbsp;
<p>int IDL_Load(void)
<br>{
<br>&nbsp; /*
<br>&nbsp;&nbsp; * These tables contain information on the functions and
procedures
<br>&nbsp;&nbsp; * that make up the TESTMODULE DLM. The information contained
in these
<br>&nbsp;&nbsp; * tables must be identical to that contained in testmodule.dlm.
<br>&nbsp;&nbsp; */
<br>&nbsp; static IDL_SYSFUN_DEF function_addr[] = {
<br>&nbsp;&nbsp;&nbsp; { testfun, "TESTFUN", 0, IDL_MAXPARAMS, 0},
<br>&nbsp; };
<p>&nbsp; static IDL_SYSFUN_DEF procedure_addr[] = {
<br>&nbsp;&nbsp;&nbsp; { (IDL_FUN_RET) testpro, "TESTPRO", 0, IDL_MAX_ARRAY_DIM,
0},
<br>&nbsp; };
<br>&nbsp;
<p>&nbsp; /*
<br>&nbsp;&nbsp; * Create a message block to hold our messages. Save its
handle where
<br>&nbsp;&nbsp; * the other routines can access it.
<br>&nbsp;&nbsp; */
<br>&nbsp; if (!(msg_block = IDL_MessageDefineBlock("Testmodule", ARRLEN(msg_arr),
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
msg_arr)))
<br>&nbsp;&nbsp;&nbsp; return IDL_FALSE;
<p>&nbsp; /*
<br>&nbsp;&nbsp; * Register our routine. The routines must be specified
exactly the same
<br>&nbsp;&nbsp; * as in testmodule.dlm.
<br>&nbsp;&nbsp; */
<br>&nbsp; return IDL_AddSystemRoutine(function_addr, TRUE, ARRLEN(function_addr))
<br>&nbsp;&nbsp;&nbsp; &amp;&amp; IDL_AddSystemRoutine(procedure_addr,
FALSE, ARRLEN(procedure_addr));
<br>}
<br>&nbsp;
<pre>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</pre>
&nbsp;</html>
Re: IDL_FileOpen problem? [message #20413 is a reply to message #20344] Fri, 16 June 2000 00:00 Go to previous message
Nando Iavarone is currently offline  Nando Iavarone
Messages: 48
Registered: December 1998
Member
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
Vince Hradil wrote:
<blockquote TYPE=CITE><style></style>
<font face="Arial"><font size=-1>Is
it possible that this is an 'endian' problem?</font></font></blockquote>

<p><br>I don't think.
<br>It is the same machine that writes and reads, without byte swap.
<pre>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</pre>
&nbsp;
</body>
</html>
Re: IDL_FileOpen problem? [message #20417 is a reply to message #20344] Fri, 16 June 2000 00:00 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Is it possible that this is an 'endian'
problem?</FONT></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<DIV>"Nando Iavarone" &lt;<A
href="mailto:f.iavarone@acsys.it">f.iavarone@acsys.it</A>&gt; wrote in message
<A
href="news:39466AB0.FBA20EE4@acsys.it">news:39466AB0.FBA20EE4@acsys.it</A>...</DIV>Ben
Tupper wrote:
<BLOCKQUOTE TYPE="CITE">Hello,
<P>My eyes tend to glaze over when I see c code... but I think I see that
<BR>you are expecting your 'foo' file to be binary format. <BR>If so, you
should set the BINARY keyword to OPENW since the default <BR>behavior on WIN
platforms is to write in text format. <BR>&nbsp;</P></BLOCKQUOTE>
<P><BR>Hi Ben, <BR>sorry for your eyes&nbsp; ;o)
<P>I don't think so because I am writing unformatted. <BR>In fact the result
is the same (and IDL_FileOpen should warrantee portability). <BR>I tried also
to write the file using the IDL_FileOpen in write mode and using the c-fwrite
function. Nothing changes.
<P>I am waiting for the RSINC support answer.
<P>Thank you. <BR>&nbsp;&nbsp; Best regards,
<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Nando <PRE>--&nbsp;
Nando Iavarone
Advanced Computer System - SPACE DIVISION
via Lazzaro Belli, 23
00040&nbsp; Frascati - RM
Tel: +39-6-944091 (switchboard)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 9440968 (direct)
E-mail:&nbsp;
&nbsp;&nbsp;&nbsp; f.iavarone@acsys.it
&nbsp;&nbsp;&nbsp; FrdndVrn@altavista.net</PRE>&nbsp;
</BLOCKQUOTE></BODY></HTML>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Flaw found in histogram on Red Hat Linux
Next Topic: coordinate conversion factor woes in object graphics

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 08:11:22 PDT 2025

Total time taken to generate the page: 0.32193 seconds