<ul><li><p>Visual Logic Instructions and Assignments Visual Logic can be installed from the CD that accompanies our textbook. It is a nifty tool for creating program flowcharts, but that is only half of the story. Until this software came along, flowcharts were static diagrams that outlined the flow of execution of a computer program. When a Visual Logic flowchart is done, you can run the program behind the flowchart. This is a great learning resource for budding programmers. You can even create interactive programs that allow the user to input values for variables at runtime. Visual Logic is a terrific tool for grasping basic programming concepts such as variables, operators, expressions, branching, and looping. It is excellent preparation for more sophisticated programming with Visual Basic.NET. We hope you like it! Install Visual Logic on your home PC by accepting all defaults in the installation wizard. Then, put the CD away in a safe place. Once installed, Visual Logic can be started in the usual way from the Windows Start menu. On the splash screen shown here, click on Continue to produce the starting flowchart. The starting flowchart displays a Begin and End symbol as shown. To create a flowchart, you add symbols between these starting </p><p>symbols. Lesson One : Sample Visual Logic Program ( perform the actions that are in boldface ) Hover your mouse over the red arrow between the Begin and End symbols. It will turn green, indicating that you can click on it to get a popup window. This popup window has the other symbols we will need to create programs. </p><p>Click on the green arrow and select the Output symbol. This inserts the Output symbol into the flowchart as shown. The Output symbol produces output on the display screen. Next, we will specify what the program should output. Double click on the Output symbol to get the </p><p>Output dialog box. </p></li><li><p>Output that consists of a text message must be </p><p>enclosed in quotes. This is called a string. </p><p> The button in the lower left corner of the Output dialog toggles between More >> and reveals that there are 3 Output types. For now, leave the type as Dialog Box as shown. Enter your own name and be sure to enclose it within quotes. Later, we will use variables that dont use quotes. Click on the OK button when done, and the Output symbol will change to show your intended output. </p><p>Run the program by clicking on the button on the toolbar, or by pressing the F5 function key. </p><p>Your name should appear in a popup dialog box as shown above on the right. If you got red error windows like the one on the left, you likely forgot one, or both, quotes. We all do this now and then but, no problem, its easy to debug. Just close the error windows, double click on the Output symbol, and add the quotes around your name. Run it again and it should work fine. </p><p>Click on the green arrow below the first Output symbol to add another Output symbol. Make this second Output generate the output Visual Logic is fun. Run the program again. Did you remember the quotes? You should get two popup dialogs, one after the other. Edit the first Output by clicking the More >> button. Select console. An odd looking line feed symbol, , will be appended to your name. This is normal for console output. </p></li><li>Summary Text output must be enclosed within quotes The More>> and </li><li><p>Visual Logic Assignment One Create a Visual Logic program named VLogic1.vls that uses four Outputs. The first three Outputs should create a console window similar to the one shown here. Specify your name, place of birth, and hobby or pastime. The fourth Output should create the popup dialog box exactly as shown. </p><p> This is the console window. </p><p> This is the popup dialog window. </p><p>Save the program as VLogic1.vls Lesson Two ( perform actions in boldface ) Start a new Visual Logic program with File | New on the menu. Insert an Input symbol. The Input symbol is a parallelogram like the Output symbol, but unlike Output, it leans to the right. Double click on the Input symbol and click More>> to expand the window. Inputs are special because they enable a user to enter data when the program runs. Inputs require you to specify a variable name and a prompt. The prompt will inform the user of the expected input, and the variable will accept and hold what the user enters. Complete the Input as shown. Insert another Input below the first Input. Configure this Input to ask a user for his/her age as shown. Pay attention to the case of your variable names. These names follow the variable naming convention used in Visual Basic. </p></li><li><p>NOTE: If you forget to specify a prompt in an Input, Visual Logic will supply a generic prompt that is not very user friendly. Avoid this by expanding the Input with More >> and specifying a helpful prompt. Insert an Assignment symbol (a rectangle ) below the second Input. Assignment symbols interpret an expression on the right side of an = sign and assign the result to a variable named on the left side of the = sign. You can start receiving Social Security payments at age 62. The Assignment shown above computes the number of years before a user could start receiving payments and stores it in a variable named SocialStart. Insert an Output below the Assignment. Configure the Output as shown here. Explanation of this Output This Output introduces the & (ampersand) symbol in Outputs. The & is used to link strings of characters enclosed in quotes with variables that do not use quotes. Computer programmers called this linking concatenation. In this case, we have the variable YourName concatenated with the short string is , the variable Age, and the string years of age. The spaces inside the strings are necessary to avoid jamming the variables up against characters in the strings. Insert another Output above the End symbol. Configure it as shown below. </p><p> This Output concatenates the SocialStart variable between the two strings. Again, note the spaces after in and before years are essential for good quality output. </p><p>Run the program by clicking on the button on the toolbar, or by pressing the F5 function key. Here is a sample run of the program: </p><p>NOTE: When prompted to input your name, enclose it in quotes. Always use quotes around text Inputs. Do not enclose the number entered for your age. Never use quotes with numeric input. </p></li><li><p> If you got a red error screen, check your work for quotes. Its easy to forget one. Edit all Inputs and Outputs by clicking on More >> and selecting the console option. The small white rectangle will indicate the console. In the first Output, press Enter with the cursor in front of the line feed symbol . The program should appear as below on the left. </p><p> Run the program again to see the console output. It should appear as below: </p><p>Save the program as example2.vls on your system. Whether you choose console output or dialog output is often a matter of personal preference. Console output is better when you need to review your previous Inputs later in a program. </p></li><li><p>Summary An Input symbol is used to enter data into a program during a program run Inputs store the entered data in variables, and are best with helpful prompts Text input must be within quotes but numeric input is never inside quotes An Assignment symbol interprets an expression and stores the result in a variable The Assignment symbol in a flowchart is a rectangle Always use meaningful variable names. For example, use Age for agenot x The & character is used to concatenate variables and strings in Outputs Spaces at the beginning or end of strings avoids jams when concatenating </p><p>Visual Logic Assignment Two Create a Visual Logic program that prompts the user to enter two numbers and then displays the sum, product, and average of the numbers. The entire program should run in one console window. Here are two sample runs: </p><p> Save the program as VLogic2.vls. Hints </p><p> Use the * operator for multiplication as shown You will need sharp concatenation skills to get the outputs. Always place an & </p><p>between a variable and a quoted string You will need 2 Inputs, 3 Assignments, and at least 1 Output. It can be done with </p><p>one Output (by pressing Enter for line feeds) but if you use 3 Outputs thats OK. Lesson Three ( perform actions in boldface ) </p></li><li><p>This assignment simulates a checkout in a retail store and covers these Visual Logic skills: Inputting non-numeric values for variables The built-in CurrencyFormat function A complete list of arithmetic operators </p><p> Start a new Visual Logic program. Insert an Input symbol, and use it to prompt the user to enter his/her name as shown. Remember to enclose the prompt in quotes, and select console. Add a few spaces before the closing quote, too. Add two more Input symbols, one for the unit price of a merchandise item, and the other for the quantity purchased. Use console, appropriate variable names, and suitable prompts for both Inputs. Now use an Assignment symbol to calculate the extended price (unit price x quantity) and store it in another variable. At this point, the sample program should look something much like the graphic on the right. Finally, use an Output symbol (in console) to summarize all of the Inputs. The final output might be as shown here. The entire program consists of just five symbols, namely three Inputs, one Assignment, and one Output (in that order). NOTE: When entering the name, use quotes. Always use quotes for non-numeric inputs. NOTE: This Output generated the final three lines of output. FormatCurrency </p></li><li><p>Visual Logic has a number of built-in functions. The FormatCurrency function can produce better output for the UnitPrice and ExtPrice in our sample program. To use FormatCurrency, identify the variable to be formatted inside the parentheses ( ) as shown next. </p><p> Adding FormatCurrency function (in two locations) </p><p>New output with currency format where suitable Save this example as retail.vls Arithmetic Operators The following table summarizes the Visual Logic arithmetic operators, and their usage in arithmetic expressions. You will use most of these in future assignments. Operator Operation Example Explanation </p><p>+ addition Sum = 5 + 3 Sum = 8 - subtraction Diff = 5 - 3 Diff = 2 * multiplication Product = 5 * 3 Product = 15 / real division Quotient = 5 / 3 Quotient = 1.6666666 integer division Answer = 5 3 Answer = 1 ( no decimals ) ^ exponentiation Power = 5 ^ 3 Power = 125 ( 5*5*5 ) </p><p>Mod modulus Remainder = 5 Mod 3 Remainder = 2 NOTE: modulus is another term for the remainder after division. Some more examples: 22 Mod 5 evaluates to 2 ( 5 divides into 22 four times with 2 remainder ) 36 Mod 7 evaluates to 1 ( 7 divides into 36 five times with 1 remainder ) </p></li><li><p>Summary Always enclose non-numeric input within quotes Press enter in an Output symbol to get a line feed (for a new line) Visual Logic has seven arithmetic operators The FormatCurrency function can be used to display dollars and cents </p><p>Visual Logic Assignment Three Create a Visual Logic program that calculates a users weekly paycheck. The program should prompt the user for his/her name, rate of pay, and hours worked. Then, the program should summarize the input. Strive to duplicate this output (all in the console). Note the currency formats in the output. Save as payroll.vls. </p><p> Lesson Four ( perform actions in boldface ) Virtually all computer programs of any significance can make decisions and execute different branches of code based on the decision outcome. Often this means that one block of code will execute if a specified condition is true, but another block of code will execute if that condition was false. In most programming languages, branching is achieved with IF. Visual Logic is no exception. To illustrate branching, we will create a Visual Logic program that determines if a user is old enough to vote in the USA. Start a new Visual Logic program and set up an Input symbol as shown here. The Dialog Box option is selected. Insert an IF condition symbol immediately after the Input. Note that the IF symbol is a diamond. Note too that the IF creates two branches, True and False. The False branch is also known as the ELSE branch. Double click on the IF diamond to get the dialog box. This allows us to enter the condition for the IF symbol. In our case, the condition must test the users age. </p></li><li><p>Enter Age >= 18 as the condition. Then click OK. The symbol >= means greater than or equal to, and as you know the voting age is 18 in the USA. NOTE: All IF conditions are expressions that evaluate to either True or False. NOTE: All IF conditions use one or more conditional operators. See a list on the next page. Next, we add symbols to each branch of the IF. Insert an Output in the True branch. Configure it to output You are of voting age. Insert an Output in the False branch that will output You are too young to vote. Your completed program should look like this: </p><p>Run the program a few times. Try ages older and younger than 18. Try 18, too. Save the program as agevote.vls. The program should respond properly with respect to the Age variable. This simple program used only one symbol in both branches of the IF, but multiple operations in each branch are common. </p><p>Operators Used for IF conditions Conditional Operator Explanation </p><p>< Less than > Greater than = Greater than or equal to = Equal to Not equal to </p></li><li><p>Nested IFs The branches of an IF diamond can themselves contain IFs that have their own branches. This is called nesting. For example, a program that qualifies a voter in the USA should ensure that the user is a US citizen, in addition to the age test. Lets try this. Delete the Output in the True branch of voteage.vls </p><p>and in its place add the Input symbol for Citizen shown here. Insert an IF symbol under the Citizen Input in the True branch. Specify the condition as shown here. Add Outputs to the branches of this second IF as shown Save it again. Run the program with different ages and try both possible responses to the Citizen Input. Make sure that you use quotes around your response to the Citizen Input. The output should be what would be expected. If not, contact your instructor. The entire program should now appear as shown next. If your program gets too expansive for the display, reduce the % on the toolbar. </p></li><li><p>Compound Conditions By using logical operators, programmers can create compound conditions for IF symbols. </p><p>Logical Operators Operator Explanation </p><p>AND Less than OR Greater than NOT Less than or equal to </p><p>As an example of a compound condition, we will modify the previous program to make it detect a teenager. Load the voteage.vls program if necessary. Save it as teenager.vls (to make a copy). Delete everything under the Age Input. Add an IF diamond and edit the condition as shown here. Click OK. This compound condition will be True for a teenager, since teenagers are aged between 13 and 19, inclusive. Note that there are two distinct conditions...</p></li></ul>
Units R Value configured in DDC file via Visual Logic Priority Array R/W Limit 0.4 Description R/W Read only if configured in DDC header via Visual Logic Status Flags R Usually no flags set.0.
Alerton Controls
- Option #1: Right-click here to download Visual Logic. If you are having problems downloading, you can use a different web browser (such as Mozilla FireFox) or you can get the ZIP file from option #2 below. Option #2: Right-click here to download a ZIP file containing Visual Logic. You can save the ZIP file to your machine and then unzip the.
- Dec 18, 2012Â Applied logic: Creating your first program 'Hello World!' Using Visual Logic. Applied logic: Creating your first program 'Hello World!' Visual logic: your first program.mp4 Meri Engel.
- Programmer’s guide and reference. User agreement and limited warranty important - purchase of alerton products or use of software, firmware and / or accompanying documentation (defined below) is subject to license restrictions and limited warranty. Carefully read this agreement before using alerton products, software.