#include "fintrf.h"
C Gateway routine
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
C mexFunction arguments:
mwPointer plhs(*), prhs(*)
integer nlhs, nrhs
C Function declarations:
mwPointer mxCreateString
mwPointer mxGetString
mwPointer mxGetM, mxGetN
integer mxIsChar
C Array information:
mwPointer mrows, ncols
C Arguments for computational routine:
mwSize maxbuf
parameter(maxbuf = 100)
character*120 line
integer*4 k
character*100 input_buf
mwPointer strlen
C Check for proper number of arguments.
if(nrhs .ne. 1) then
write(line,*) 'error: incorrect number of input arguments'
k=mexPrintf(line//achar(13))
return
C The input must be a string.
elseif(mxIsChar(prhs(1)) .ne. 1) then
write(line,*) 'error: input argument is not a string'
k=mexPrintf(line//achar(13))
return
endif
C Get the size of the input string.
mrows = mxGetM(prhs(1))
ncols = mxGetN(prhs(1))
C Get the length of the input string and validate.
strlen = mrows*ncols
if (strlen .gt. maxbuf) then
write(line,*) 'error: input is greater than max str size'
k=mexPrintf(line//achar(13))
return
endif
C Get the string.
status = mxGetString(prhs(1), input_buf, maxbuf)
write(line,*) 'str = ', input_buf
k=mexPrintf(line//achar(13))
return
end
Best Answer