En Tue, 08 Apr 2008 06:02:17 -0300, Michael Schäfer <[EMAIL PROTECTED]> escribió:
> Gabriel, > > works perfect - even in complex nested structures! > Thank you very much! > >> (If both Fortran and VB say "char*9", why did you choose a pointer >> here?) > I do not know this possibility. Could you please drop me a few lines? (It's just what I posted and you said it worked) In C, strings are usually represented as an array of characters implicitely ending at the first NULL character. By example: `char foo[20]` declares a string variable named foo with enough space for up to 19 characters (plus the final NULL character). A very common way of refer to such strings is to pass a pointer to its first character: `char *pfoo` declares a variable pfoo which can hold a reference to a string variable allocated somewhere (this is the usual way to pass a string argument to a function). In ctypes terminology, the first type is declared as c_char*20, and the second one is c_char_p. In FORTRAN you'd use CHARACTER*20 FOO (or CHARACTER(20)::FOO) to declare a string variable with up to 20 characters, right padded with spaces. The appropiate way to declare this with ctypes is then to use c_char*20 (and probably initialize it with spaces, and trim spaces on the right coming from Fortran). c_char_p declares a pointer, but Fortran filled it as it were an array of characters: the first 4 letters of "Sample", when read as a little-endian integer, give 0x706D6153, the "invalid pointer" you got. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list