SetAttachment

set the attachment (text, Maple structures, files) to the linked MapleSim model

Parameters

 name - string ; name of the attachment content - anything ; content of the attachment options - (optional) equation(s) of the form name = value

Returns

 • none

Options

 • category : one of the following: "custom", "datasets", "cad", "other", "documents"
 Specifies the category where the attachment should be placed. Default is "documents".
 • filecopy : true or false
 If set to true, the content parameter is assumed to be a name of the file to be attached to the active model. Default is false.

Description

 • A:-SetAttachment sets the attachment to a linked model A.
 • The A := MapleSim:-LinkModel() statement needs to be run prior to successfully using any of the ModelObject A's export functions.

Examples

 > $A≔\mathrm{MapleSim}:-\mathrm{LinkModel}\left('\mathrm{filename}'=\mathrm{cat}\left(\mathrm{kernelopts}\left('\mathrm{toolboxdir}'=\mathrm{MapleSim}\right),"/data/examples/RLCcircuit.msim"\right)\right):$

 > $\mathrm{data}≔"this will be the ship"$
 ${\mathrm{data}}{≔}{"this will be the ship"}$ (1)
 > $A:-\mathrm{SetAttachment}\left("data.txt",\mathrm{data},'\mathrm{category}'="other"\right)$

 > $L≔\left[1,2,3,4\right]:$
 > $A:-\mathrm{SetAttachment}\left("data.csv",L,'\mathrm{category}'="datasets"\right)$

Getting the data from the attachment:

 > $A:-\mathrm{GetAttachment}\left("data.csv"\right)$
 $\left[\begin{array}{cccc}{1.}& {2.}& {3.}& {4.}\end{array}\right]$ (2)

 > $A:-\mathrm{ListAttachments}\left(\right)$
 $\left[{"data.txt"}{,}{"data.csv"}\right]$ (3)
 > $A:-\mathrm{ListAttachments}\left(\mathrm{showcategories}=\mathrm{true}\right)$
 $\left[\left[{"data.txt"}{,}{"other"}\right]{,}\left[{"data.csv"}{,}{"datasets"}\right]\right]$ (4)

 > $\mathrm{fd}≔\mathrm{FileTools}:-\mathrm{Text}:-\mathrm{Open}\left("samplefile.txt",\mathrm{create}=\mathrm{true},\mathrm{overwrite}=\mathrm{true}\right):$
 > $\mathrm{FileTools}:-\mathrm{Text}:-\mathrm{WriteString}\left(\mathrm{fd},"This is a test file."\right):$
 > $\mathrm{FileTools}:-\mathrm{Text}:-\mathrm{Close}\left(\mathrm{fd}\right):$
 > $A:-\mathrm{SetAttachment}\left("sampleAttachedFile.txt",\mathrm{cat}\left(\mathrm{currentdir}\left(\right),"/samplefile.txt"\right),\mathrm{filecopy}=\mathrm{true}\right):$
 > $A:-\mathrm{ListAttachments}\left(\right)$
 $\left[{"data.txt"}{,}{"data.csv"}{,}{"sampleAttachedFile.txt"}\right]$ (5)