You are viewing an older revision! See the latest version

Importing code

The mbed Compiler makes it easy to import code published on mbed.org or located on your local machine.

Importing from mbed.org

The Import Wizard allows you to import programs and libraries published by mbed users. This is useful for importing code that has been packaged as a reusable library component (e.g. a class for a peripheral), so you can quickly pull in the building blocks for your project.

/media/uploads/screamer/import-wizard-pub1-view.png

To import a program you have to select a shared program from the list and click the "Import" button like shown on the image above. The Import dialog will let you define the import destination, type and name, and in the given example it would look like:

/media/uploads/screamer/import-wizard-pub2-prog.png

The "Import Name" field will be pre-filled based on the selected program or library. The "Import As" allows you to change the import type regardless of the published type, thus you can import programs as libraries and vice-versa. In given the example "HelloWorld" could be imported as library in a program (see below).

/media/uploads/screamer/import-wizard-pub3-lib.png

The Import dialog interface would be transformed to reflect the "Import As" selection and in this case two new options will be added - "Target Path" and "New Program" both of which define the import destination.

"Target Path" defines destination programs, folders and libraries that already exist in your workspace, "New Program" will create new empty program with a given name and import the desired library in it. Note that "Target Path" and "New Program" override each other and valid option would be the latter specified/modified.

Once the required fields are filled and validated, the "Import" button will be activated, indicating that you can import the specified program or library.

Alternative methods

If you don't want to fiddle with the Import dialog options, one way to quickly import a resource is to initially select the desired destination in the navigation tree, then open the Import Wizard, and double-click the desired program or library (alternatively you can hit "Enter" key). The properties of the imported resource will be based on the nav tree selection:

  • If a program/folder is selected, the resource will be imported as library, if "My Programs" is selected, the resource will be imported as program instead.
  • The import name will be populated from the resource name.
  • If a duplicate or other conflict is detected, the Import dialog will be opened to guide you through. Alternative

If you have opened the Import Wizard already and would like to quickly import a resource without changing the navigation tree selection, then you can simply drag and drop the resource from the list into your workspace. Similar to the behavior described above, the resource will be imported based on the drop target.

Multiple import

It's also possible to select multiple items in the Import Wizard using the Ctrl/Shift+Click combo and import them either via the Import dialog/button or drag and drop them in your workspace. This, so called batch mode, will attempt to import all selected resources even if a conflict or error occurs during import.


All wikipages