Information Technology Reference
In-Depth Information
then the function call would be processed to com-
pletion before going on to the next line in the script,
meaning that the process would complete running all
the way! You can do this with a script call, but since
you can't Stop() from within the script, it doesn't get
recorded by default.
to the script file at this point in the editor, then you
should hit the Compile button in the script window to
re-compile the script and incorporate your changes into
the thing that actually gets run. You might notice that
you get a couple of warning messages about not finding
the SetUnique function — ignore these. If you made
a mistake in editing the file, you might notice other er-
rors or warnings — it is always a good idea to look at
these (especially errors) when you hit Compile ,and
see if you can figure out what is wrong.
Now, you are ready to run the script.
B.3.6
Saving Files from the Script
There is one final (and difficult to correct) bug on what
should be the last line of your script:
Hit the Run button.
You should see several windows coming up as the ob-
jects were created (network, environment, etc.). How-
ever, these windows are blank initially — don't panic.
Just hit the Init buttons to initialize these displays.
You can poke around the network, environment, and so
on, and ReInit and Run the process to see that every-
thing is the same as when you first created it!
One thing you might have noticed is that the original
window positions were not saved in the script. We can
remedy this in the following way.
.projects[0].SaveAs(ostream_ref);
The problem is that it has this ostream_ref argu-
ment instead of the actual file name that we want to save
into. This happens because by the time the SaveAs
function is called, it has lost any record of the actual file
name, and so cannot record it here in the script. Thus,
you have to edit this line, providing the entire name of
the project you want to save (including the extension,
which is added automatically for you in the graphical
interface, but not here):
First, position the windows in the way that you want
them. Then, start Record again in the script window.
This will append newly recorded script code to the
end of your existing program.
.projects[0].SaveAs("constr.proj.gz");
Be sure to save the resulting script file with your bug
fixes before proceeding.
Then, do Object/Edit in the process window. In
the resulting edit dialog, select Script All Win Pos
from the Object menu in the edit dialog (this is an ex-
panded version of the Object menu that appears in the
project window). Then, hit Stop Rec in the script win-
dow, and Edit the script file again (or just revert your
editor if you still have it there).
You should notice some additional lines at the end of
the script that call SetWinPos functions on the var-
ious objects (and Place on the control panel). Then
close this project, and repeat the steps for creating a
new project and running the script again. You should
find that the windows appear in their saved locations
this time around.
While this exercise of using the script to create the
project is useful for learning how to program in the
script language, it is not the most useful way to save
and load projects. It is much easier just to use SaveAs
on the project object, and then do Open In to load it
, !
B.3.7
Compiling and Running the Script
Now that we have made it all the way through the script,
and you have edited out any mistakes that you might
have made along the way, we can actually compile and
run it, which should result in the reproduction of the
same project we just finished setting up. To do this, we
have to start out with an empty project.
Go to the project window and do Object/Close
and click on Ok to get rid of the current project.
Then, do .projects/New/Project in the remaining
PDP++ Root window, to create a new project. As be-
fore, create a new script object in the .scripts menu,
and this time, Open the recorded script file.
When you hit the Apply button in the script window,
this script will automatically be compiled . Compiling
the script turns the text file into something that the com-
puter can actually run.
If you were to make changes
Search WWH ::




Custom Search