From: Etienne on
Hi Folks

Does anybody have a Fortran example of how mxGetString is used? I have looked at the C-example, but this has not really helped with Fortran.

Regards

Etienne
From: James Tursa on
"Etienne" <etienne.coetzee(a)airbus.com> wrote in message <hm11es$li5$1(a)fred.mathworks.com>...
> Hi Folks
>
> Does anybody have a Fortran example of how mxGetString is used? I have looked at the C-example, but this has not really helped with Fortran.
>
> Regards
>
> Etienne

Try this (pass in a char string variable):

! caution, untested

#include "fintrf.h"
mexFunction(nlhs, plhs, nrhs, prhs)
!-ARG
integer*4 nlhs, nrhs
mwPointer plhs(*), prhs(*)
!-FUN
integer*4, external :: mxGetString
integer*4, external :: mexPrintf
!-LOC
integer*4 k
character*50 line
mwSize :: strlen = 50
!-----
line = ' '
k = mxGetString(prhs(1), line, strlen)
k = mexPrintf("The string passed in was "//line//achar(10))
return
end

James Tursa
From: Etienne on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hm18a8$ik2$1(a)fred.mathworks.com>...
> "Etienne" <etienne.coetzee(a)airbus.com> wrote in message <hm11es$li5$1(a)fred.mathworks.com>...
> > Hi Folks
> >
> > Does anybody have a Fortran example of how mxGetString is used? I have looked at the C-example, but this has not really helped with Fortran.
> >
> > Regards
> >
> > Etienne
>
> Try this (pass in a char string variable):
>
> ! caution, untested
>
> #include "fintrf.h"
> mexFunction(nlhs, plhs, nrhs, prhs)
> !-ARG
> integer*4 nlhs, nrhs
> mwPointer plhs(*), prhs(*)
> !-FUN
> integer*4, external :: mxGetString
> integer*4, external :: mexPrintf
> !-LOC
> integer*4 k
> character*50 line
> mwSize :: strlen = 50
> !-----
> line = ' '
> k = mxGetString(prhs(1), line, strlen)
> k = mexPrintf("The string passed in was "//line//achar(10))
> return
> end
>
> James Tursa

Thanks James