C BMax value passing

BlitzMax Forums/BlitzMax Programming/C BMax value passing

splinux(Posted 2006) [#1]
I have a C file with a char ptr var:
static char *abc;

How could i read it with BMax and print it?

I've tryied

import "file.c"

extern
global abc:string ptr
end extern

print abc



But it says that is impossible to convert from string ptr to string.


Perturbatio(Posted 2006) [#2]
try $z or Byte Ptr instead of String Ptr


splinux(Posted 2006) [#3]
it says:
unable to convert from byte ptr to string.


splinux(Posted 2006) [#4]
i have to receive this var from a c file, and then write it to a file.


Stuart Morgan(Posted 2006) [#5]
Use FromCString() like this...

Test.bmx
Import "test.c"

Extern
    Function GetABC:Byte Ptr()
End Extern

Print String.FromCString(GetABC())

test.c
char* abc = "Hello World";

char* GetABC(void)
{
    return abc;
}




splinux(Posted 2006) [#6]
YES, IT WORKS!!!!
THANKS Stuart Morgan.

With this problem solved, my Linux Webcam Module is almost finished.

I have to thank you very much.

I'll put your nick into my credits.

I think i'll release the module one of these days.

:)


splinux(Posted 2006) [#7]
i don't know where the problem is:
it aquires all the image somethimes, and a few bytes or kbytes other times.


splinux(Posted 2006) [#8]
writing data using writestring or writeline writes data as ascii.
i need to print them as int.
i'll try writeint.

however sometimes it works and sometimes not.

if anyone has suggests, please post.


Dreamora(Posted 2006) [#9]
Do you read them again with readInt and not readByte or something similar?


splinux(Posted 2006) [#10]
I need to write them.

However i've changed it to writestring and it now works perfectly!

!!!

:)