6 How to Create and Upload App


This topic shows you how to create an X-Function based App called Rotate Curve and upload to File Exchange

Create App

Create Folder

To create a folder for the App

  1. Open Code Builder, right click Apps folder on Workspace tab
  2. Select New. Untitled folder is created.
  3. Right click Untitled and choose Rename. Enter Rotate Curve as App name.

  4. CreateApp Folder.png

  5. Right click on Rotate Curve and choose Open Folder in File Explorer to see where the folder is in Windows Explorer.

Create Files

This simple App will need 3 files:

  • X-Function to do the rotation of curve
  • LabTalk script file which is called when clicking on the App icon in Apps Gallery window.
  • Icon image to show in Apps Gallery and Apps Center.

Create X-Function

This step will create RotateCurve.oxf to rotate a curve(XY dataset).

  1. Go back to Origin workspace and click menu Tools: X-Function Builder....
  2. In X-Function field, enter RotateCurve
  3. Click Save button to save it to the Rotate Curve folder created in previous step ...\Apps\Rotate Curve\
  4. In Variables table, right click in the table to add two more variables.
  5. Set them as image below:
    CreateApp XF.png
  6. Click the Code Builder buttonOcguide xfdialog codebuilderbutton.png to open the code in Code Builder and paste in the following code:
    	vector vx, vy, vxOut, vyOut;
    	
    	ixy.GetData(vy, vx);	
    	double theta2 = theta/180*pi;
    	vxOut = cos(theta2)*vx - sin(theta2)*vy;
    	vyOut = sin(theta2)*vx + cos(theta2)*vy;		
    	
    	oxy.SetData(&vyOut, &vxOut);
  7. Click the Compile button and then click the Return to Dialog button to go back to X-Function Builder
  8. Click Ocguide xfdialog savebutton.png button again and close X-Function builder.

Create LabTalk File

When clicking the installed App in Apps Gallery window, we can specify it to run LabTalk file launch.ogs, which in turn runs the X-Function.

This step will create such file:

  1. Go back to Code Builder window
  2. Right click Rotate Curve folder and choose New File....
  3. Pick LabTalk Script File, and enter launch as file name and click OK.
  4. Add a [Main] section with LabTalk Script to open the RotateCurve X-Function dialog:
    [Main]
    RotateCurve -d;
  5. Click Save button

It can launch not only an X-Function dialog, but also HTML dialog, GetN dialog (OriginC or LabTalk), DLL dialog and so on.

Create App Icon

A 32x32 icon png image file is needed to display the App in Apps Gallery. The file can be saved with any color depth and even transparency.
For this tutorial, please save this as AppIcon.png onto local PC.

CreateApp Icon.png

Add Files to the App folder

3 files are needed for this simple App: RotateCurve.OXF, launch.ogs and AppIcon.png. So far, if you expand Rotate Curve folder on Code Builder, only launch.ogs is under it. We need to add other files there as well.

  1. On Code Builder, right-click on Rotate Curve and select Add Files...
  2. Browse to select RotateCurve.oxf and click OK.
  3. Right click on Rotate Curve and select Add Files.... Find AppIcon.png and click OK.
  4. Right click on Rotate Curve and choose Open Folder in File Explorer. All files are put to the app folder.

Pack App

Apps are usually packed as OPX file for future distribution and installation.

  1. Right click on Rotate Curve and select Generate... to open Package Manager.
    CreateApp Pack.png
  2. Edit the fields, in image below. Some important fields are:
    • Launch Script is the place to specify the code to run when the icon is clicked in the App Gallery. In this case, enter launch.ogs, which will run the [Main] section.
    • Icon to specify the image file
    • Enable by Window is used to specify when the App will be available. For windows unchecked, the app will be grayed out.

  3. CreateApp PackMg.png
  4. In the Pack Manager dialog, click File menu and choose Save to save it as Rotate Curve.OPX file on someone on the PC. No need to be under the corresponding app folder.
  5. Then you can drag& drop Rotate Curve.opx to install the App.

Submit App to File Exchange

If you are not going to upload the App, you can ignore this section. But if you want to upload the App to File Exchange, 2 images are needed

  1. ScreenShot: png file, shown in the app page, size < 100K.
  2. Preview: png file, 300*200, shown in File Exchange main page.

Go to FileExchange and click Submit a file -> create a support ticket. Add the opx file and the ScreenShot&Preview images as attachment. Origin's support team will help you to upload the App to File Exchange.
CreateApp SubmitTicket.png

After upload, the web page of the App will be like:
CreateApp Screenshot2.png


Update the OPX

We will probably want to continue developing the App by adding or changing the code files or App icon, and then we can update the OPX file with the latest changes.

  1. In Origin, new a Project and fill Book1's Col(A) and Col(B) with some data, and save this project as Rotate Cruve.opju in ..\Apps\Rotate Curve\Samples to be this App's sample data.
  2. In Code Builder, right-click on Rotate Curve and select Add Files... to add Rotate Cruve.opju.
  3. Right-click again on the App folder in the Workspace tab and select Generate....
  4. All the fields are already filled with the last-used values. Generally, we can just increment the Version number and save the OPX file.
    CreateApp update.png
  5. If your App was uploaded to File Exchange, please go to FileExchange and click Submit a file -> create a support ticket. And tell Origin's support team the modification in description field.