Problem with Imported Fuction in Procedure

Just starting out? Need help? Post your questions and find answers here.
HotteHC
User
User
Posts: 19
Joined: Fri Feb 29, 2008 7:44 am

Problem with Imported Fuction in Procedure

Post by HotteHC »

Hi at all.
I think i found a buck while importing some Library-Functions:

Code: Select all


#SEEK_SET_=0
#SEEK_CUR_=1
#SEEK_END_=2

EnableExplicit

Import "libcpmt.lib"
 fopen(fname$,fmode$)
 fclose(c_stream.l)
 fread(*buf,size.l,count.l,c_stream.l)
 fwrite(*buf,size.l,count.l,c_stream.l)
 fflush(c_stream.l)
 fseek(c_stream.l,offset.l,origin.l)
 ftell(c_stream.l)
 feof(c_stream.l)
 fgetc(c_stream.l)
 fputs(str$,c_stream.l)
 ungetc(char.l,c_stream.l)
EndImport

Procedure _FileSize(_stream)
 
     Protected curpos.l, length.l;
     Debug _stream
     curpos = ftell(_stream);
     Debug _stream ;-> streampointer is changed ?!?!?!?
     fseek(_stream, 0, #SEEK_END_);
     length = ftell(_stream);
     fseek(_stream, curpos, #SEEK_SET_);
     ProcedureReturn length;
 EndProcedure

OpenConsole()

 Global stream.l,le.l

 stream = fopen("Scene1.bmp", "r+");
    
 le.l = _FileSize(stream)
 Print("FileLength : "+str(le))

Repeat : Until Inkey()
CloseConsole()
End
When I run this Code, it gives me following Error:
"read error at address 1700773832"


I tried it with the latest Beta and with the 4.10 of PB.

But anyway I must say that I love programming in PB ;-)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

When you import 'C' function, you have to use ImportC
HotteHC
User
User
Posts: 19
Joined: Fri Feb 29, 2008 7:44 am

Post by HotteHC »

:oops:

Thanks for the quick replay. My fault!
Post Reply