What settings are retained/restored when file is opened?

Questions about GP commands and how to do things

Moderator: MSandro

Post Reply
Posts: 12
Joined: Jul 31st, '17, 00:24

What settings are retained/restored when file is opened?

Post by bkgray » Oct 20th, '17, 13:36

When a GPP file is opened, some settings are restored to their values when the file was last saved. For example, when I:
  • open a new project
  • drag the ship to (300, 200)
  • save to a new project
  • close GP Blocks environment
  • re-start GP Blocks
  • load the previously saved project
the ship will appear at (300, 200). The previous position of the ship is restored.

My students and I have determined that the settings that are restored include the location, color and direction of an object. We accidentally discovered that the alpha value (as specified in "set alpha" from the Looks menu) is also restored. Our current project involves working with the alpha channel in colors. A student mistakenly clicked on "set alpha" (with it's default value of 0.5) instead of expanding the "color" block to reveal the spot for an alpha value. Clicking on the "set alpha" block changed the alpha value. That change was retained when the project was saved and restored when the project was opened later.

Is there a list of all of the settings that are restored when a project is loaded? In other words, what values must be explicitly set as part of the initialization to guarantee a consistent environment when the program is run?
  • location
  • direction
  • scale
  • alpha
  • etc, etc, etc

Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: What settings are retained/restored when file is opened?

Post by SimpleSi » Oct 20th, '17, 15:24

Its easier to say that EVERYTHING is saved/restored except for

Current running state of blocks (i.e if a script was actually running when the project was saved - it will not to be restored to that point - but the value of any shared/instance variables will be the value they were when the project was saved)

GUI window pane position/sizes are not restored

Developer mode is not restored

Show arrows is set to true

Monitors of variables are not restored if they were not placed on the stage

Which class is selected defaults to top one in the list - not the one selected when project saved

Posts: 379
Joined: Sep 11th, '15, 14:42

Re: What settings are retained/restored when file is opened?

Post by JohnM » Oct 23rd, '17, 22:34

As SimpleSi wrote, everything that one can consider the "content" of the project is saved, including the state of all instances on stage and the contents of shared variables, as well as all the classes and scripts the user has created.

The state of the UI and it's tools (e.g. any windows like color pickers or the paint editor) get's reset when you restart GP. Most UI state is also reset when you open or create a new project except a few things like "developer mode".

This makes GP a bit different from most programming languages where state must always be recreate when the program starts up (or explicitly read in from a file, server, or other data source). A GP project is a combination of code (like Java or other languages) and a multimedia document (such a Word or PowerPoint document). This combination is very natural for beginners, including very young children, but when making the transition to other programming languages it is probably worth being explicit about the fact the programs in most languages need to initialize variables, create objects, and load media every time they start up. To simulate that in GP, you could have your students always clear the stage before saving their project and write code to reinitialize variables and create instances at startup. One can add an "initialize" method to any class that will get run when a new instance is created. This method can do thing like setting the instance's position, rotation, scale, costume, etc.

Hope that help!

-- John

Posts: 12
Joined: Jul 31st, '17, 00:24

Re: What settings are retained/restored when file is opened?

Post by bkgray » Oct 24th, '17, 01:20

SimpleSi and JohnM -

Thanks for your responses. We'll incorporate that into our lessons.

We have been preaching the need for initializing instance vars on instances of objects, and for doing some initialization in response to a Go. We'll just have to expand the list of settings that we initialize to create the environment that we want.

The recent problem that caused some confusion (for the student and for me) was caused by an errant click on the alpha(0.5) block (which resulted in subsequent images and colors appearing washed out. After figuring out what was happening, fixing it was easy (by adding a set alpha(1.0) to the start-up script.

Post Reply