Skip to content

scala-subscript/examples

Repository files navigation

SubScript examples

This repository contains several small SubScript example applications. LookupFrame2TBD is a training assignment.

Prerequisites

You will need the following software in order to run the examples:

  1. Git client - official website, download manual
  2. SBT build tool - official website, download manual

Getting started

To try the examples:

  1. Clone this repository by running git clone https://github.com/scala-subscript/examples.git
  2. Go to the root of the repository: cd examples
  3. Launch the SBT console by running sbt
  4. Run projects from the SBT console. You will see the list of all the examples in the repository, each belonging to its own project. root is not an example, but the root project, so ignore it.
  5. To run an example, run the <example_project_name>/run command, where <example_project_name> is the name of the desired example, as listed in the projects command's output. For example, if you want to try the "lookupframe" example, run lookupframe/run.
  6. Some examples have more then one object with the main method. In this case the console will prompt you to specify what you want to run. In case of "Lookup Frame", entering 1 in the prompt will run a simple "LookupFrame", and entering 2 will run the more complex "LookupFrame2".
  7. In order to start developing with SubScript, please head to the main repository and follow its "Getting Started guide"

Debugging the projects

You can use graphical debugger to see how the projects work. To do so:

  1. From the examples' root, run sbt.
  2. Set the current project to a desired one: project projectName, where projectName is a name from projects command output.
  3. Some projects have more than one main class. To see the project's main classes, run show discoveredMainClasses.
  4. If the project has more than one main class, you'll have to specify which one you want to debug: set mainClass in Compile := Some("main_class_name"), where main_class_name is some name from the show discoveredMainClasses output (see the complete list of commands for setting the main class below). If the project has only one main class, no action is needed, it will be used automaticaly.
  5. Run ssDebug.

Commands for setting the main class

  • Lookup frame (project lookupframe)
    • set mainClass in Compile := Some("subscript.example.LookupFrame")
    • set mainClass in Compile := Some("subscript.example.LookupFrame2")
    • set mainClass in Compile := Some("subscript.example.LookupFrame2TBD")
  • AB (project ab)
    • set mainClass in Compile := Some("subscript.example.AsBX")
    • set mainClass in Compile := Some("subscript.example.AsBsX")
    • set mainClass in Compile := Some("subscript.example.Bag")
    • set mainClass in Compile := Some("subscript.example.Bag_A")
    • set mainClass in Compile := Some("subscript.example.Bag_AB")
    • set mainClass in Compile := Some("subscript.example.Bag_AB_loops")
  • Hello World (project helloworld)
    • set mainClass in Compile := Some("subscript.example.Hello")
    • set mainClass in Compile := Some("subscript.example.HelloWorld")
    • set mainClass in Compile := Some("subscript.example.Hello_1_World")

Examples description

  • helloworld is a classic Hello World application
  • ab is a swing application to demonstrate some basic scripts
  • lookupframe demonstrates a more complex use case of scripting in the context of Swing
  • life is the Game of Life simulator
  • twitter searches Twitter's most recent tweets with a given keyword. Features dataflow, where the application is reactively bound to the input field, so that any input causes a new search.
  • pingpong is a use case of SubScript Akka Actors. Two actors that exchange a message three times.
  • taskprocessor is a more complex example of SubScript Actors. An actor system that is designed to process any given task by forking it, delegating parts to different actors and then joining the results together.

Repository structure

The repository contains multiple SBT project folders with the corresponding examples. build.sbt is a multi-project build file binding the examples together. Each of the example projects is defined by its own build.sbt that can be found in its folder. The SubScript SBT plugin is defined for all the projects in project/build.sbt.

Releases

No releases published

Packages

No packages published

Languages