GetCharArray - Get character array from server

Synopsis

MATLAB® Client

string = h.GetCharArray('varname', 'workspace')
string = GetCharArray(h, 'varname', 'workspace')
string = invoke(h, 'GetCharArray', 'varname', 'workspace')

Method Signature

HRESULT GetCharArray([in] BSTR varName, [in] BSTR Workspace, 
[out, retval] BSTR *mlString)

Microsoft® Visual Basic® Client

GetCharArray(varname As String, workspace As String) As String

Description

GetCharArray gets the character array stored in the variable varname from the specified workspace of the server attached to handle h and returns it in string. The workspace argument can be either base or global.

Remarks

If you want output from GetCharArray to be displayed at the client window, you must specify an output variable (e.g., string).

Server function names, like GetCharArray, are case sensitive when using the first syntax shown.

There is no difference in the operation of the three syntaxes shown above for the MATLAB® client.

Examples

Assign a string to variable str in the base workspace of the server using PutCharArray. Read it back in the client with GetCharArray.

MATLAB® Client

h = actxserver('matlab.application');
h.PutCharArray('str', 'base', ...
   'He jests at scars that never felt a wound.');
S = h.GetCharArray('str', 'base')
S =
  He jests at scars that never felt a wound.

Visual Basic® .NET Client

This example uses the Visual Basic® MsgBox command to control flow between MATLAB and the Visual Basic Client.

Dim Matlab As Object
Dim S As String
Matlab = CreateObject("matlab.application")
MsgBox("In MATLAB, type" & vbCrLf _
    & "str='new string';")

Open the MATLAB window, then type:

str='new string';

Click Ok.

Try
    S = Matlab.GetCharArray("str", "base")
    MsgBox("str = " & S)
Catch ex As Exception
    MsgBox("You did not set 'str' in MATLAB")
End Try

The Visual Basic MsgBox displays what you typed in MATLAB.

See Also

PutCharArray, GetWorkspaceData, PutWorkspaceData, GetVariable, Execute

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS