Jump to content
IGNORED

Workfile management in Pascal


apersson850

Recommended Posts

Anyone who has ever written an assembly program using the Editor/Assembler package knows the drill.

  • Use the editor to create the source file.
  • Save it as MYFILE:S
  • Run the assembler to convert MYFILE:S to a codefile MYFILE:O.
  • Use the Load and Run to execute the code file.

 

When creating a Pascal program with the p-system, you can do almost exactly the same. The procedure is then, in detail, like this:

  • Press E to start the editor, followed by ENTER to start a new program.
  • Use the editor to type in the source code for your program.
  • Quit the editor, then Write to a filename. Type in myfile and ENTER to save the file. Press Exit to leave the editor.
  • Now press C to compile the program. Type in myfile as the source to compile and $ to create the codefile with the same name.
  • When the compiler has finished, press eXecute to run your program. Enter myfile and it will run your new program.

 

As you can see, this mimics the Editor/Assembler workflow almost exactly.

The p-system has another card up its sleeve, though. It's called the workfile. As the name hints, it's the file you are working with. Assuming you don't already have a workfile, the same task as I described above will now run like this:

  • Press E to start the editor, followed by ENTER to start a new program.
  • Use the editor to type in the source code for your program.
  • Quit the editor, then Update to create the workfile and leave the editor.
  • Press Run to execute your program.

 

That's it. The p-system will check if your latest workfile has been compiled. In this case it has not, so it will compile it for you, and then execute it.

The next time you select Run, the program will run immediately, as it's already compiled.

 

It should be obvious that the workfile concept saves several keystrokes, when you are creating your program. If you run it and find you want to edit something, you simply invoke the editor and it will open the workfile for you, no questions asked.

 

So, what's the drawback? Well, as long as you are working on one program, and that program fits in one single source file, then none, really. To start a new program, you have to go to the Filer and Save the current workfile under some filename, like myfile. Then you can create a New workfile (also with the filer), exit it and open the editor to enter the text into your new workfile. While in the Filer, you can also check What your current workfile is, and Get any existing file to become the workfile.

However, the features inherent in the p-system, some of which I've described in earlier posts, does invite you to create substantial projects. Such projects frequently consist of a main program file, a file to include in the main program file, a file with the source for a separately compiled unit and a file with assembly support for either the unit or the main program. When you have several files like that, the maneuvers to get the correct file to become your current workfile, each time you want to change something, aren't worth it. There's no automation of assembling a source file either.

 

Personally, I never use the workfile. But if you are new with the system, then it's likely that you start by creating software where it works well.

 

A note about filenames. When using the Editor/Assembler, most users adapt some method to tell the difference between the source and object code. They don't have the same file format, so you can tell from that what's what, but you can still not have the same file name for both. My method was usually to name them TEST:S and TEST:O or something similar.

With the p-system, although you normally use ten character file names there too, they are really 15 characters long. When you tell the Editor to create the file myfile, it will actually save the file as myfile.text. And when you tell the compiler to compile myfile to the same filename, it will actually compile myfile.text to myfile.code. That's why you can seemingly use the same filename for both the source and the code. They aren't the same, actually. If you did use the workfile in the example above, and then wanted to save it as myfile, you would open the Filer and tell it to save the workfile to myfile. It will then report that it has copied *SYSTEM.WRK.TEXT to MYFILE.TEXT and *SYSTEM.WRK.CODE to MYFILE.CODE.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...