Adding an attachment while developing an Xpress Insight app can be as simple as creating a file in the project_attachments directory.
The example project is to be extended by loading some standard investment warning advice from a string stored in an app-level attachment. Initially, it will contain placeholder text, but later, it will be edited and updated from the app itself, demonstrating how the model interacts with attachments.
- Create a file called caution.txt and save it in your app's project_attachments folder - its contents should be:
cautionText:"** Text to be replaced **"
The organization of your app now looks like:
Folder Hierarchy After Adding an Attachment
- Change the parameters section of foliodata.mos so that it contains an entry for the name of the relevant attachment:
parameters
! Name of attachment to contain caution text
CAUTIONTEXT = "caution.txt"
! File with problem data
DATAFILE = "folio.dat"
! Output file
OUTFILE = "result.dat"
...
end-parameters
- Change the first declarations section of foliodata.mos so that it contains a declaration for the string value to be ultimately read from caution.txt:
declarations
...
RET: array(SHARES) of real
changeShare: string
cautionText: string
end-declarations
- Change the datainput procedure in foliodata.mos so that it now reads:
! Load input data
procedure datainput
insightgetprojattach(CAUTIONTEXT)
initializations from DATAFILE
RET RISK NA
end-initializations
initializations from CAUTIONTEXT
cautionText
end-initializations
changeShare:= "brewery"
end-procedure
The call to
insightgetprojattach causes
Xpress Insight to locate the
caution.txt file in
project_attachments, and copy it into its working directory, whereupon it can be manipulated using Mosel's standard data manipulation functions.
The second call to initializations initializes the cautionText value with that assigned in caution.txt - i.e. ** Text to be replaced **.
- Change foliodata.vdl so that its first few lines now read:
<vdl version="4.1">
<vdl-page>
<vdl-section heading="Welcome to Portfolio Optimization"
heading-level="1">
<span vdl-text="=scenario.entities.cautionText.value"></span>
<vdl-section heading="Return per share" heading-level="2">
...
The
<span> element has a
vdl-text attribute that uses an expression to evaluate and insert the runtime value of the
cautionText entity.
© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the
property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not
convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except
solely for internal evaluation purposes to determine whether to purchase a license to the software
described in this documentation, or as otherwise set forth in a written software license agreement
between you and FICO (or a FICO affiliate). Use of this documentation and the software described in
it must conform strictly to the foregoing permitted uses, and no other use is permitted.