
-----------------------------------
jayshaw94
Wed Apr 20, 2011 8:42 am

Coding
-----------------------------------
Hello compsci

3 Questions.
1) There are 4 options for one answer. 0,0.5,1,2. The user must choose one of those options if not an error will be shown and the program will then loop back. My question is how would I code that? I tried the 'or' option with no luck (if op1 not = 0 or 0.5 or 1 or 2 then put "error")

2) I have a bunch of procedures. The procedures are called at the end of the program. My program calculates height/width based on certain things. Each procedure will show the calucations for the height and frame. I would then like to put/show those calculations at the end of the program again.

Example: Once the program has finished the bottom will state the height/width/etc for everything. How would I do that. Here is my coding so far. Any help would be great. Thank you guys!

3) Why is it that the put statement will not excute after calling the procedures?

var da, choice1, choice2, nojp, nosp, nocw, nocjp, nocsp, h1, h2, h3, w1, w2, w3, choice, HOF1, HOF2, WOF1, howi, wowi, hogi, wogi, howi1, wowi1, hogi1, wogi1 : int
var afw1, afw2a, afw2b, afw3, afw4a, afw4b, afw5, op1, op2, op3, op4, op5, od, TTLI : real
var RailA := 46
var RailB := 41


procedure Form1
    HOF1 := (h1) - (RailA) %Height of frame based on RailA= Lowest Room Height substract 46%
    HOF2 := (h1) - (RailB) %Height of frame based on RailB= Lowest Room Height substract 41%
    howi := (HOF1) - (58) %Height of wooden infill based on RailA= height of frame based on RailA substract 58%
    wowi := (w1) - (23) %Width of wooden infill based on RailA= lowest room width substract 23%
    hogi := (HOF1) - (60) %Height of glass infill based on RAilA= heigh of frame based on RailA substract 60%
    wogi := (w1) - (20) %Width of glass infill based on RailA= lowest room width substract 20%
    howi1 := (HOF2) - (58) %Height of wooden infill based on RailB= Height of Frame based on RailB substract 58%
    wowi1 := (w1) - 23 %Width of wooden infill based on RailB= lowest room width substract 23
    hogi1 := (HOF2) - (60) %Height of glss infill based on RailB= Height of Frame base on RailB substract 60
    wogi1 := (w1) - (23) %Width of glass infill based on RailB= lowest room width substract 23

    if choice = 1 then
        put "Height of frame: ", HOF1, " Width of Frame: ", w1, " The Height of the wooden infill is: ", howi, " The Width of the wooden infill is: ", wowi 
            %Outputs height and width of frame as well as wooden infill based on RailA%
    elsif choice = 2 then
        put "Height of frame: ", HOF1, " Width of Frame: ", w1, " The Height of the glass infill is: ", hogi, " The Width of the glass infill is: ", wogi 
            %Outputs height and width of frame as well as glass infill based on RailA%
    elsif choice = 3 then
        put "Height of Frame: ", HOF2, " Width of Frame: ", w1, " The Height of the wooden infill is: ", howi1, " The Width of the wooden infill is: ", wowi1 
            %Outputs height and width of frame as well as wooden infill based on RailB%
    elsif choice = 4 then
        put "Height of Frame: ", HOF2, " Width of Frame: ", w1, " The Height of the glass infill is: ", howi1, " The Width of the wooden infill is: ", wowi1 
            %Outputs height and width of frame as well as glass infill based on RailB%
    end if
end Form1


procedure RailChoice %Option for rail et on the floor or set into floor as well as infill type%
    put "Rail A (1)Set on the Floor with Wooden infill"
    put "Rail A (2)Set on the Floor with Glass infill"
    put "Rail B (3)Set into the Floor with Wooden infill"
    put "Rail B (4)Set into the Floor with Glass infill"
    get choice
    loop
        if choice > 4 then
            put "Error please try again"       %If user picks an option greater than 4 error is given%
            RailChoice
        end if
        exit when choice  12 then
        put "Exceeds 12mm limit Rail B is the default"                   %If any of the two heights that are substracted are greather than 12 this error message is given%
    elsif (h2) - (h3) > 12 then
        put "Exceeds 12mm limit Rail B is the default"
    elsif (h3) - (h1) > 12 then
        put "Exceeds 12mm limit Rail B is the default"
    elsif (h1) - (h3) > 12 then
        put "Exceeds 12mm limit Rail B is the default"
    end if
end hwconfig


procedure OpeningDeductions
    put "Enter the number of Jumbo post(s) required"
    get nojp
    put "Enter either 0, 0.5, 1, or 2"
    get op1
    TTLI := (w1) - (100) * (op1) + (2)
    put "Enter the number of Small post(s) required"
    get nosp
    put "Enter either 0, 0.5, 1, or 2"
    get op2
    put "Enter the number of connection(s) to wall"
    get nocw
    put "Enter either 0, 1, or 2"
    get op3
    put "Enter the number of connection(s) to Jumbo Post"
    get nocjp
    put "Enter either 0, 1, or 2"
    get op4
    put "Enter the number of connection(s) to Small Post"
    get nocsp
    put "Enter either 0 or 1"
    get op5
    od := (100) * (nojp) + (op1) + (44) * (nosp) + (op2) + (36) * (nocw) + (op3) + (36) * (nocjp) + (op4) + (36) * (nocsp) + (op5)
    put "Opening Deductions: ", od, "MM"
    put "Top Track Length inside the opening: ", TTLI, "MM"
end OpeningDeductions



procedure D_A
    put "Number of door(s) to be used"
    get da
    if da = 1
            then
        put "1 Option:"
        put "1) Type of Track: Single Number of Rubber Seals 1 Number of Overlaps:0"
        afw1 := (w1 - 6) * (1) + (19) - (od)
        put "Actual Frame Width: ", afw1
    elsif da = 2
            then
        put "2 Options:"
        put "1) Type of Track: Single Number of Rubber Seals:1 Number of Overlaps:0"
        put "2) Type of Track: Double Number of Rubber Seals:2 Number of Rubber Seals:1"
        put "Enter option 1 or 2"
        get choice1
        if choice1 = 1 then
            afw2a := (w1 - 6) * (1) + (19) - (od)
            put "Actual Frame Width: ", afw2a
        elsif choice1 = 2 then
            afw2b := (w1 - 6) * (2) + (19) * (1) - (od)
            put "Actual Frame Width: ", afw2b
        else
            D_A
        end if
    elsif da = 3
            then
        put "2 Options:"
        put "1) Type of Track: Double Number of Rubber Seals:2 Number of Overlaps:2"
        put "2) Type of Track: Triple Number of Rubber Seals:2 Number of Overlaps:2"
        afw3 := (w1 - 6) * (2) + (19) * (2) - (od)
        put "Actual Frame Width: ", afw3
    elsif da = 4
            then
        put "2 Options:"
        put "1) Type of Track: Double Number of Rubber Seals:2 Number of Overlaps:3"
        put "2) Type of Track: Double Number of Rubber Seals:3 Number of Overlaps:2"
        put "Enter option 1 or 2"
        get choice2
        if choice2 = 1 then
            afw4a := (w1 - 6) * (2) + (19) * (3) - (od)
            put "Actual Frame Width: ", afw4a
        elsif choice2 = 2 then
            afw4b := (w1 - 6) * (3) + (19) * (2) - (od)
            put "Actual Frame Width: ", afw4b
        else
            D_A
        end if
    elsif da = 5
            then
        put "1 Option:"
        put "1) Type of Track: Double Number of Rubber Seals:2 Number of Overlaps:4"
        afw5 := (w1 - 6) * (2) + (19) * (4) - (od)
        put "Actual Frame Width: ", afw5
    end if
    loop
        if da > 5
                then
            put "Error door limit has been exceeded please try again"
            D_A
            exit when da  4 then 
put "Error please try again" %If user picks an option greater than 4 error is given% 
RailChoice 
end if 
exit when choice 