function [stat,post] = blkwvar(path,prop,bstr,bint,bflt,parent,name)
%BLKWVAR Copies signal values from a model to a global simulation variable,
%
%  See also BLKRVAR, BLKDSMEM

% Initial coding by A S Bozin, 20-3-98
% Copyright 1997-2000 The MathWorks, Inc.
% $Revision: 1.5 $ $Date: 2000/06/14 16:11:40 $

   stat = 0;					   % Error flag
   nInputs = bint(5);
   nOutputs = bint(6);
   nStates = bint(7);
   %
   % Get the variable name
   %
   indInt = bint(15)+1;
   mode = bint(indInt);
   indInt = bint(18)+1;
   indStr = bint(20)+1;
   ind = mfindstr(bstr,indStr,'|');
   varName = bstr(indStr:ind-1);
   indInt = bint(indInt)+indInt;		   % Skip icon data
   ndims = bint(indInt+4);			   % Number of dimension
   dRange = 1:3;
   hdr = bint(indInt+dRange);
   dRange = 5:4+ndims;
   dim = bint(indInt+dRange);			   % Dimensions
   dRange = dRange+ndims;
   ind = bint(indInt+dRange);			   % Indices
   switch (hdr(3))				   % Addressing type
   case 1					   % All
      %
      % Add mux and demux blocks if necessary
      %
      [post,rect] = blkio('port',nInputs,nOutputs,prop,path);
      %
      % Goto block
      %
      bh = add_block('built-in/Goto',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'GotoTag',varName,...
		     'TagVisibility','global');
      %
      % Connect the current write to variable block with the mux and demux blocks
      %
      blkio('line',nInputs,nOutputs,post,parent,name);
   case {2,3}				   % Element or bit
      [stat,post] = blkunknown(path,prop,bstr,bint,bflt,'Write to Variable');
   otherwise
   end
   return					   % Last card of BLKWVAR



