Announcement

Collapse
No announcement yet.

New in BASIC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • New in BASIC

    Hi members

    I have got this code and i dont know how to make use of it. Could anyone please lend me a hand with regards to this.

    Thanks in advance.

    Any Questions please PM me thanks.

    Rem ----- Input Data -----
    No.ofSeats = 4
    Baggage = 60
    Fuel = 60
    FPDrag = 2.6
    Clmax = 1.9
    No.ofEngines = 1
    Power = 200
    RPM = 2800
    WingArea = 136
    CanardArea = 21
    TailArea = 45
    WingAR = 9.56
    CanardAR 6.48
    TailAR = 5.6
    Rem ----- Aircraft Design Program -----
    Print ""
    If CanardArea <> 0 Then GoTo 120
    CanardArea = 0.0000000001
    CanardAR = 1
    If TailArea <> 0 Then GoTo 130
    TailArea = 0.0000000001
    TailAR = 1
    TotArea = WingArea + CanardArea
    WF = Fuel * 6
    UL = 170 * No.ofSeats + Baggage + WF
    GW = UL / 0.4
    EW = GW - UL
    PP = No.ofSeats * 170
    VS = Sqr(840.34 * GW / (TotArea * Clmax))
    VSmph = VS * 682
    Cwing = Sqr(WingArea / WingAR)
    Bwing = WingArea / Cwing
    Ccanard = Sqr(CanardArea / CanardAR)
    Bcanard = CanardArea.Ccanard
    Ctail = Sqr(TailArea / TailAR)
    Btail = TailArea / Ctail
    V = Sqr(1682 * Power * No.ofEngines / FPDrag)
    Dia = 360 * (Power / (V * RPM ^ 2)) ^ 0.25
    Rem ----- Maximum Speed -----
    Tstatic = No.ofEngines * 7.38 * (Power * Dia) ^ 0.667
    Vm = 0
    Vm = Vm + 2
    TD = Tstatic * (1 - 0.106 * Vm * Sqr((RPM * Dia ^ 3) / (Power * 10 ^ 7)))
    Drag = 0.00119 * FPDrag * Vm ^ 2
    If Drag > TD Then GoTo 250
    If Drag < TD Then GoTo 225
    Vmph = Vm * 0.68
    Rem ----- Propeller Diameter -----
    Dia = 360 * (Power / (Vm * RPM ^ 2)) ^ 0.25
    Din = 12 * Dia
    Rem ----- Performance-----
    Vcruise = 0.85 * Vm
    Vcmph = 0.68 * Vcruise
    CLcruise = 2 * GW / (0.00238 * TotArea * Vcruise ^ 2)
    Alpha = 57.3 * CLcruise * (TotArea + 2) / (6.283 * TotArea)
    Vcl1 = Sqr(GW * 840.34 / TotArea)
    ROC = 60 * Vcl1 * (10.44 * Power * No.ofEngines / (GW * Sqr(GW / TotArea)) - 0.02 - 1 / (3.14 * WingAR))
    SFC = 0.000446 * Power ^ 2 - 0.0125 * Power + 2.79
    Range = Fuel * Vcmph / SFC
    Rem ----- Output -----
    Print " Empty Weight ="; Int(EW); "Ibs"
    Print " Pilot and Passanger ="; Int(PP); "Ibs"
    Print " Baggage ="; Int(Baggage); "Ibs"
    Print " Fuel ="; Int(WF); "Ibs"
    Print " Useful Load ="; Int(UL); "Ibs"
    Print " Gross Weight ="; Int(GW); "Ibs"
    Print " Flat Plate AD ="; FPDrag
    Print " No. of Seats ="; No.ofSeats
    Print " No. of Engines ="; No.ofEngines
    Print " Engine Power ="; Power; "hp"
    Print " Propeller Speed ="; RPM; "rpm"
    Print " Total Static Thrust ="; Int(Tstatic); "Ibs"
    Print " Propeller Diameter ="; Int(Din); "inches": Print ""
    Print "": Print "": Print "": Print ""
    Print " Wing Area ="; WingArea; "sq.ft"
    Print " Wing Span ="; Bwing; "feet"
    Print " Average Speed ="; Cwing; "feet"
    Print " Cruise Lift Coef. ="; CLcruise
    Print ""
    Print " Canard Area ="; CanardArea; "sq.ft"
    Print " Canard Span ="; Bcanard; "feet"
    Print " Canard Chord ="; Ccanard; "feet"
    Print " Tail Area ="; TailArea; "sq.ft"
    Print " Tail Span ="; Btail; "feet"
    Print " Tail Chord ="; Ctail; "feet"
    Print "": Print "": Print ""
    Print "": Print "": Print "": Print "": Print "": Print ""
    Print " Maximum Speed ="; Int(Vmph); "mph"
    Print " Cruise Speed ="; Int(Vcmph); "mph"
    Print " Stall Speed ="; Int(VSmph); "mph"
    Print " Maximum ROC ="; Int(ROC); "mph"
    Print " Range no Reserve ="; Int(Range); "miles"
    Print "": Print "": Print "": Print "": Print "": Print "": Print ""

  • #2
    I don't understand what you mean by "make use of it", but if you mean you'd like to use it after porting to one of the PB for Windows compilers, then the logic is pretty clear, but PRINT is not used with PB/Windows (It's valid in PB/CC), you'll have to put all that code inside a function or sub, and you'll have to find line 120 since there is a GOTO that line.

    BTW, if you ask here you will get answered here. Not only is "PM" not an option for some of us (in fact some of us - eg moi - don't know what that is) , but if you ask everyone to help it seems a bit presumtuous to ask for personal assistance.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      After death?

      Originally posted by Michael Mattias
      (...)Not only is "PM" not an option for some of us (in fact some of us - eg moi - don't know what that is) (...)
      PM means: Post Mortum which is After Death in English. So he wants help once he lies in his grave?

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment


      • #4
        I'd believe he means PM to be an Private Message ... but Post Mortem on his code is not possible with so many missing parts, the autopsy would be inconclusive.

        Here's a quick PBCC translation of what is there. Note that it cops out for defining the vars with DEFSNG ... which we are warned my become extinct in a future version of the product. Also it fixes the GOTO's with stub code that exits the program. Additionally it is going to exit as it is because of the first IF test.

        Christopher: Dots in a variable name are for use with UDT structures and COM vars, otherwise they will not compile. There is also no WITH keyword in PB, so you have to use a bit more verbose coding .. . but there is not enough information in your post to speculate further.

        The mantra for help is post code. all that is needed to understand the code problem ... or give a link to a source listing if it is extensive.

        If you have PBCC then this code should plug right in. However with PBWin you will need to define a GUI to display the PRINTed information, or simply output to a printer (LPRINT/XPRINT) with a bit more code.

        Code:
        #COMPILE EXE
        FUNCTION PBMAIN () AS LONG
            DEFSNG a-z
            NoOfSeats = 4
            Baggage = 60
            Fuel = 60
            FPDrag = 2.6
            Clmax = 1.9
            NoOfEngines = 1
            Power = 200
            RPM = 2800
            WingArea = 136
            CanardArea = 21
            TailArea = 45
            WingAR = 9.56
            CanardAR = 6.48
            TailAR = 5.6
        REM ----- Aircraft Design Program -----
            PRINT ""
            IF CanardArea <> 0 THEN GOTO Bail1
            CanardArea = 0.0000000001
            CanardAR = 1
            IF TailArea <> 0 THEN GOTO Bail1
            TailArea = 0.0000000001
            TailAR = 1
            TotArea = WingArea + CanardArea
            WF = Fuel * 6
            UL = 170 * NoOfSeats + Baggage + WF
            GW = UL / 0.4
            EW = GW - UL
            PP = NoOfSeats * 170
            VS = SQR(840.34 * GW / (TotArea * Clmax))
            VSmph = VS * 682
            Cwing = SQR(WingArea / WingAR)
            Bwing = WingArea / Cwing
            Ccanard = SQR(CanardArea / CanardAR)
            ' was: Bcanard = CanardArea.Ccanard
            Bcanard = CanardArea/Ccanard
            Ctail = SQR(TailArea / TailAR)
            Btail = TailArea / Ctail
            V = SQR(1682 * Power * NoOfEngines / FPDrag)
            Dia = 360 * (Power / (V * RPM ^ 2)) ^ 0.25
            REM ----- Maximum Speed -----
            Tstatic = NoOfEngines * 7.38 * (Power * Dia) ^ 0.667
            Vm = 0
            Vm = Vm + 2
            TD = Tstatic * (1 - 0.106 * Vm * SQR((RPM * Dia ^ 3) / (Power * 10 ^ 7)))
            Drag = 0.00119 * FPDrag * Vm ^ 2
            IF Drag > TD THEN GOTO Bail3
            IF Drag < TD THEN GOTO Bail4
            Vmph = Vm * 0.68
            REM ----- Propeller Diameter -----
            Dia = 360 * (Power / (Vm * RPM ^ 2)) ^ 0.25
            Din = 12 * Dia
            REM ----- Performance-----
            Vcruise = 0.85 * Vm
            Vcmph = 0.68 * Vcruise
            CLcruise = 2 * GW / (0.00238 * TotArea * Vcruise ^ 2)
            Alpha = 57.3 * CLcruise * (TotArea + 2) / (6.283 * TotArea)
            Vcl1 = SQR(GW * 840.34 / TotArea)
            ROC = 60 * Vcl1 * (10.44 * Power * NoOfEngines / (GW * SQR(GW / TotArea)) - 0.02 - 1 / (3.14 * WingAR))
            SFC = 0.000446 * Power ^ 2 - 0.0125 * Power + 2.79
            Range = Fuel * Vcmph / SFC
            REM ----- Output -----
            PRINT " Empty Weight ="; INT(EW); "Ibs"
            PRINT " Pilot and Passanger ="; INT(PP); "Ibs"
            PRINT " Baggage ="; INT(Baggage); "Ibs"
            PRINT " Fuel ="; INT(WF); "Ibs"
            PRINT " Useful Load ="; INT(UL); "Ibs"
            PRINT " Gross Weight ="; INT(GW); "Ibs"
            PRINT " Flat Plate AD ="; FPDrag
            PRINT " No. of Seats ="; NoOfSeats
            PRINT " No. of Engines ="; NoOfEngines
            PRINT " Engine Power ="; Power; "hp"
            PRINT " Propeller Speed ="; RPM; "rpm"
            PRINT " Total Static Thrust ="; INT(Tstatic); "Ibs"
            PRINT " Propeller Diameter ="; INT(Din); "inches": PRINT ""
            PRINT "": PRINT "": PRINT "": PRINT ""
            PRINT " Wing Area ="; WingArea; "sq.ft"
            PRINT " Wing Span ="; Bwing; "feet"
            PRINT " Average Speed ="; Cwing; "feet"
            PRINT " Cruise Lift Coef. ="; CLcruise
            PRINT ""
            PRINT " Canard Area ="; CanardArea; "sq.ft"
            PRINT " Canard Span ="; Bcanard; "feet"
            PRINT " Canard Chord ="; Ccanard; "feet"
            PRINT " Tail Area ="; TailArea; "sq.ft"
            PRINT " Tail Span ="; Btail; "feet"
            PRINT " Tail Chord ="; Ctail; "feet"
            PRINT "": PRINT "": PRINT ""
            PRINT "": PRINT "": PRINT "": PRINT "": PRINT "": PRINT ""
            PRINT " Maximum Speed ="; INT(Vmph); "mph"
            PRINT " Cruise Speed ="; INT(Vcmph); "mph"
            PRINT " Stall Speed ="; INT(VSmph); "mph"
            PRINT " Maximum ROC ="; INT(ROC); "mph"
            PRINT " Range no Reserve ="; INT(Range); "miles"
            PRINT "": PRINT "": PRINT "": PRINT "": PRINT "": PRINT "": PRINT ""
            PRINT "Missing code for source: Reply With Quote"
            PRINT "Press a key to exit"
            WAITKEY$
            EXIT FUNCTION
            Bail1:
                PRINT "NEED CODE FOR LINE 120"
                GOTO bailout
            Bail2:
                PRINT "NEED CODE FOR LINE 130"
                GOTO bailout
            Bail3:
                PRINT "NEED CODE FOR LINE 250"
                GOTO bailout
            Bail4:
                PRINT "NEED CODE FOR LINE 225"
                GOTO bailout
                
            Bailout:
                PRINT "Press a key to exit"
                WAITKEY$
                EXIT FUNCTION
        END FUNCTION
        Last edited by Richard Angell; 9 Jan 2008, 08:11 PM. Reason: corrected spelling
        Rick Angell

        Comment


        • #5
          Thank you guys

          Thank you guys especially Richard Angell

          I will try and work with the modified code if i dont come clear
          I will ask for more assistance.

          Thanks again

          kind regards
          Christopher

          Comment

          Working...
          X