
The SubPanel operator in ChipWits allows you to group a set of instructions into a reusable block, making complex tasks more manageable. Acting as a subroutine, it helps you organize your program into modular sections that can be called multiple times.
Note: this section deals with the Operator, SubPanel, as well as actual SubPanels (which are tabs in the Workshop that hold additional space for coding). Please go to the Please Also See section at the bottom of this page to familiarize yourself with the main panel and subpanel tabs before proceeding.
Specifications #
- Argument: None
- Creates a True or False Branch?: Yes, it does create a T/F branch
- Number of Cycles Used: 1
- Fuel: 1
Purpose of the SubPanel Operator #
- Modularity: Breaks down complex tasks into smaller, reusable blocks.
- Organization: Improves readability and debugging by keeping your code organized.
- Efficiency: Saves space by letting you call the same sequence of instructions from multiple points in your program without duplicating code.
How the SubPanel Operator Works #
- Creating a SubPanel:
- Click and create a SubPanel Chip from the Control Chips section in the Radial Workshop Menu into the Workshop grid. Please make note of which letter argument you pick as you will need to go to the SubPanel tab in the Workshop with the same letter on it.
- Inside the SubPanel tab, which corresponds with the letter on the Argument, add the necessary chips to define a specific task or action sequence.
- Calling the SubPanel:
- In the main program flow, place a SubPanel chip with corrisponding letter from the SubPanel tab wherever needed.
- When the program reaches this point, it jumps to the SubPanel, executes the contained instructions, and then returns to the main program.
- Using Arguments:
- You can pass arguments to the SubPanel to adjust its behavior based on the values provided.
Example of Using the SubPanel Operator #
Let’s say you want your ChipWit to repeatedly skate forward, check for an obstacle, and zap it if it’s an Electrocrab. Instead of duplicating this logic, you can create a SubPanel to handle it.
- In the Workshop:
- Click and create a SubPanel Chip from the Control Chips section in the Radial Action Menu in the Workshop.
- Add chips for the logic inside the SubPanel Tab:
- Skate (Move forward)
- If Thing Equals Electrocrab (Check if the obstacle is an Electrocrab)
- Zap (Zap the Electrocrab if the condition is true)
- Main Program Flow:
- Place a reference to the SubPanel Chip in the main program. Whenever your ChipWit encounters an obstacle, it will jump to the SubPanel, perform the defined actions, and then return to the main program.
Why the SubPanel Operator is Important #
- Reusability: SubPanels allow you to reuse code throughout your program, avoiding repetition and potential errors.
- Simplified Programs: Complex instructions are broken down into manageable sections, making your ChipWit’s program easier to follow and maintain.
- Customizable: With arguments, SubPanels can adapt their behavior depending on the context, providing flexibility.
Using the SubPanel Operator in the Workshop lets you create smarter, more efficient ChipWit programs that are easier to manage and adjust.
Please Also See #
History #
“SubPanel” as it appears in various historic incarnations of ChipWits!
COMMODORE 64:
MANUAL:
“Every CHIPWIT contains one Main Panel (A) and nine additional Subpanels (B through J). You can program a CHIPWIT that uses only the Main Panel (GREEDY is a good example), but eventually you’ll want to create more complicated programs that use more than one panel. The Subpanels give you plenty of extra room for programming. There are just two rules to remember:
1) A Subpanel can be “called “, or accessed, only from the Main Panel. Subpanels cannot call each other—you can’t access a Subpanel from another Subpanel.
2) When a Subpanel is finished, control always returns to the Main Panel and the program continues at the location after the chip that ca led the Subpanel.
Logically, each Subpanel might be used to perform just a single activity—searching a room, counting objects or moves, or perhaps singing a special tune.”
APPLE II:
MANUAL:
“SUB-PANEL commands the program to leave the Main-Panel and continue execution at the beginning of a specified Sub-
Panel. Since Sub-Panels can be reached only from the Main Panel, the SUB-PANEL Operator can only be used on the Main
Panel.
The Arguments for SUB-PANEL are the letters A through G. They stand for the Sub-Panel requested.
SUB-PANEL is a command to the program rather than a behavioral command to the ChipWit.”
MAC:
MANUAL:
“SUB PANEL commands the program to leave the Main-Panel and continue execution al the beginning of a specified Sub-Panel. Since Sub-Panels can be reached only from the Main Panel, the SUB-PANEL Operator can only be used on the Main Panel.
The Arguments for SUB-PANEL are the letters A through G. They stand for the Sub-Panel that you are requesting the program to go to SUB PANEL is a command to the program rather than a behavioral command to the ChipWit.”
CHIPWITS II (WIN 95):