Initializing help system before first use

Adding an Attachment in Development

Adding an attachment while developing an Xpress Insight app can be as simple as creating a file in the 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.
  1. Create a file called caution.txt and save it in your app's attachments folder - its contents should be:
    cautionText:"** Text to be replaced **"
    The organization of your app now looks like:

    Adding an Attachment

    Folder Hierarchy After Adding an Attachment

  2. 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
  3. Change the first public declarations section of foliodata.mos so that it contains a declaration for the string value to be ultimately read from caution.txt:
    public declarations
        ...
        RET: array(SHARES) of real
        changeShare: string
        cautionText: string
     end-declarations
  4. Change the datainput procedure in foliodata.mos so that it now reads:
    ! Load input data
     procedure datainput
      if insightgetmode <> INSIGHT_MODE_NONE then
      ! Model is running within Insight, so download attachment from Insight server
        insightgetappattach(CAUTIONTEXT)
        if insightattachstatus<>INSIGHT_ATTACH_OK then
          writeln("Failed to download app attachment")
          exit(1)
        end-if
      end-if
    
      initializations from DATAFILE
        RET RISK NA
      end-initializations
      initializations from CAUTIONTEXT
        cautionText
      end-initializations
      changeShare:= "brewery"
    end-procedure
    
    Note Attachment retrieval should always be accompanied by a status (error) check.
    The call to insightgetappattach causes Xpress Insight to locate the caution.txt file in 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 **.

  5. Change foliodata.vdl so that its first few lines now read:
    <vdl version="4.7">
       <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-2020 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.