Workspace_coerce()

Called to convert numbers and arrays automatically in to workspaces.

WORKSPACE_COERCE() something=Any convert "something" into a workspace (if possible)

Workspace_coerce

The default procedure definition and the calculation of errors for this procedure is shown below. This routine is called whenever a mixed type expression involving workspaces requires to convert the NON workspace parameter into a workspace. The result will always be a workspace

This is procedure is best not changed without a good understanding of how it works. It is not likely to be necessary to alter this when defining a new type of workspace.

PROCEDURE workspace_coerce; PARAMETERS something; RESULT wres

	LOCAL self

	# assign self to be the current workspace object to allow sizing & copying to the new one
	%( gXself _ line at: 1 )%

	wres=fields()					# new a workspace

	# these cases shouldn't be able to happen
	IF is_a(something, "workspace") OR is_a(something, "workspacearray")
		printen "Coercion failure - workspace(array) -> workspace"
	ELSE
		wres = self				# copy all workspace fields
        	wres.ylabel = "(dimensionless)"
        	fill wres.e 0.0
		wres.y = fill(wres.y, 0.0) + something	# use array coercion to fill the workspace
	ENDIF

ENDPROCEDURE