locked
Alignment issues in output RRS feed

  • Question

  • I'm using Small Basic Fremey extension

    When I run my program the alignment is way off. We were supplied with the array info and the headers. We were to write the loop that would display it all.

    If someone wouldn't mind taking a look and helping me out.

    thanks

    Election Results parallel arrays
    stateNames[1] = "Alabama  "
    stateNames[2] = "Alaska   "
    stateNames[3] = "Arizona  "
    stateNames[4] = "Arkansas"
    stateNames[5] = "California"
    stateNames[6] = "Colorado"
    stateNames[7] = "Connecticut"
    stateNames[8] = "D.C.        "
    stateNames[9] = "Delaware  "
    stateNames[10] = "Florida  "
    stateNames[11] = "Georgia  "
    stateNames[12] = "Hawaii   "
    stateNames[13] = "Idaho   "
    stateNames[14] = "Illinois  "
    stateNames[15] = "Indiana  "
    stateNames[16] = "Iowa    "
    stateNames[17] = "Kansas  "
    stateNames[18] = "Kentucky  "
    stateNames[19] = "Louisiana"
    stateNames[20] = "Maine   "
    stateNames[21] = "Maryland "
    stateNames[22] = "Massachusetts"
    stateNames[23] = "Michigan"
    stateNames[24] = "Minnesota"
    stateNames[25] = "Mississippi"
    stateNames[26] = "Missouri"
    stateNames[27] = "Montana  "
    stateNames[28] = "Nebraska"
    stateNames[29] = "Nevada  "
    stateNames[30] = "New Hampshire"
    stateNames[31] = "New Jersey"
    stateNames[32] = "New Mexico"
    stateNames[33] = "New York  "
    stateNames[34] = "North Carolina"
    stateNames[35] = "North Dakota"
    stateNames[36] = "Ohio    "
    stateNames[37] = "Oklahoma"
    stateNames[38] = "Oregon   "
    stateNames[39] = "Pennsylvania"
    stateNames[40] = "Rhode Island"
    stateNames[41] = "South Carolina"
    stateNames[42] = "South Dakota"
    stateNames[43] = "Tennessee"
    stateNames[44] = "Texas   "
    stateNames[45] = "Utah    "
    stateNames[46] = "Vermont  "
    stateNames[47] = "Virginia"
    stateNames[48] = "Washington "
    stateNames[49] = "West Virginia"
    stateNames[50] = "Wisconsin"
    stateNames[51] = "Wyoming  "
    
    
    stateElectoralVotes[1] = 9
    stateElectoralVotes[2] = 3
    stateElectoralVotes[3] = 10
    stateElectoralVotes[4] = 6
    stateElectoralVotes[5] = 55
    stateElectoralVotes[6] = 9
    stateElectoralVotes[7] = 7
    stateElectoralVotes[8] = 3
    stateElectoralVotes[9] = 3
    stateElectoralVotes[10] = 27
    stateElectoralVotes[11] = 15
    stateElectoralVotes[12] = 4
    stateElectoralVotes[13] = 4
    stateElectoralVotes[14] = 21
    stateElectoralVotes[15] = 11
    stateElectoralVotes[16] = 7
    stateElectoralVotes[17] = 6
    stateElectoralVotes[18] = 8
    stateElectoralVotes[19] = 9
    stateElectoralVotes[20] = 4
    stateElectoralVotes[21] = 10
    stateElectoralVotes[22] = 12
    stateElectoralVotes[23] = 17
    stateElectoralVotes[24] = 10
    stateElectoralVotes[25] = 6
    stateElectoralVotes[26] = 11
    stateElectoralVotes[27] = 3
    stateElectoralVotes[28] = 5
    stateElectoralVotes[29] = 5
    stateElectoralVotes[30] = 4
    stateElectoralVotes[31] = 15
    stateElectoralVotes[32] = 5
    stateElectoralVotes[33] = 31
    stateElectoralVotes[34] = 15
    stateElectoralVotes[35] = 3
    stateElectoralVotes[36] = 20
    stateElectoralVotes[37] = 7
    stateElectoralVotes[38] = 7
    stateElectoralVotes[39] = 21
    stateElectoralVotes[40] = 4
    stateElectoralVotes[41] = 8
    stateElectoralVotes[42] = 3
    stateElectoralVotes[43] = 11
    stateElectoralVotes[44] = 34
    stateElectoralVotes[45] = 5
    stateElectoralVotes[46] = 3
    stateElectoralVotes[47] = 13
    stateElectoralVotes[48] = 11
    stateElectoralVotes[49] = 5
    stateElectoralVotes[50] = 10
    stateElectoralVotes[51] = 3
    
    
    popularVotesForObama[1] = 811764
    popularVotesForObama[2] = 111560
    popularVotesForObama[3] = 948648
    popularVotesForObama[4] = 418049
    popularVotesForObama[5] = 7441458
    popularVotesForObama[6] = 1216793
    popularVotesForObama[7] = 979316
    popularVotesForObama[8] = 210403
    popularVotesForObama[9] = 255394
    popularVotesForObama[10] = 4143957
    popularVotesForObama[11] = 1843452
    popularVotesForObama[12] = 324918
    popularVotesForObama[13] = 235219
    popularVotesForObama[14] = 3319237
    popularVotesForObama[15] = 1367503
    popularVotesForObama[16] = 818240
    popularVotesForObama[17] = 499979
    popularVotesForObama[18] = 751515
    popularVotesForObama[19] = 780981
    popularVotesForObama[20] = 421484
    popularVotesForObama[21] = 1612692
    popularVotesForObama[22] = 1891083
    popularVotesForObama[23] = 2867680
    popularVotesForObama[24] = 1573323
    popularVotesForObama[25] = 520864
    popularVotesForObama[26] = 1439940
    popularVotesForObama[27] = 229725
    popularVotesForObama[28] = 329132
    popularVotesForObama[29] = 531884
    popularVotesForObama[30] = 384591
    popularVotesForObama[31] = 2085051
    popularVotesForObama[32] = 464458
    popularVotesForObama[33] = 4363386
    popularVotesForObama[34] = 2123390
    popularVotesForObama[35] = 141113
    popularVotesForObama[36] = 2708685
    popularVotesForObama[37] = 502294
    popularVotesForObama[38] = 978605
    popularVotesForObama[39] = 3192316
    popularVotesForObama[40] = 296547
    popularVotesForObama[41] = 862042
    popularVotesForObama[42] = 170886
    popularVotesForObama[43] = 1093213
    popularVotesForObama[44] = 3521164
    popularVotesForObama[45] = 301771
    popularVotesForObama[46] = 219105
    popularVotesForObama[47] = 1958370
    popularVotesForObama[48] = 1548654
    popularVotesForObama[49] = 301438
    popularVotesForObama[50] = 1670474
    popularVotesForObama[51] = 80496
    
    popularVotesForMcCain[1] = 1264879
    popularVotesForMcCain[2] = 179424
    popularVotesForMcCain[3] = 1132560
    popularVotesForMcCain[4] = 632672
    popularVotesForMcCain[5] = 4554643
    popularVotesForMcCain[6] = 1020135
    popularVotesForMcCain[7] = 620210
    popularVotesForMcCain[8] = 14821
    popularVotesForMcCain[9] = 152356
    popularVotesForMcCain[10] = 3939380
    popularVotesForMcCain[11] = 2048244
    popularVotesForMcCain[12] = 120309
    popularVotesForMcCain[13] = 400989
    popularVotesForMcCain[14] = 1981158
    popularVotesForMcCain[15] = 1341667
    popularVotesForMcCain[16] = 677508
    popularVotesForMcCain[17] = 685541
    popularVotesForMcCain[18] = 1050599
    popularVotesForMcCain[19] = 1147603
    popularVotesForMcCain[20] = 296195
    popularVotesForMcCain[21] = 956663
    popularVotesForMcCain[22] = 1104284
    popularVotesForMcCain[23] = 2044405
    popularVotesForMcCain[24] = 1275400
    popularVotesForMcCain[25] = 687266
    popularVotesForMcCain[26] = 1444720
    popularVotesForMcCain[27] = 241816
    popularVotesForMcCain[28] = 448801
    popularVotesForMcCain[29] = 411988
    popularVotesForMcCain[30] = 316937
    popularVotesForMcCain[31] = 1545495
    popularVotesForMcCain[32] = 343820
    popularVotesForMcCain[33] = 2576360
    popularVotesForMcCain[34] = 2109698
    popularVotesForMcCain[35] = 168523
    popularVotesForMcCain[36] = 2501855
    popularVotesForMcCain[37] = 959745
    popularVotesForMcCain[38] = 699673
    popularVotesForMcCain[39] = 2586496
    popularVotesForMcCain[40] = 165389
    popularVotesForMcCain[41] = 1034500
    popularVotesForMcCain[42] = 203019
    popularVotesForMcCain[43] = 1487564
    popularVotesForMcCain[44] = 4467748
    popularVotesForMcCain[45] = 555491
    popularVotesForMcCain[46] = 98791
    popularVotesForMcCain[47] = 1726053
    popularVotesForMcCain[48] = 1098072
    popularVotesForMcCain[49] = 394278
    popularVotesForMcCain[50] = 1258181
    popularVotesForMcCain[51] = 160639
    
    
    'Display State-by-State result chart
    TextWindow.WriteLine("State-by-State 2008 Election Results")
    TextWindow.WriteLine("")
    TextWindow.WriteLine("State              Electoral       Obama     Mccain")
    TextWindow.WriteLine("==============     =========       =======   =======")
    
    For i = 1 to Array.GetItemCount(stateNames)
      TextWindow.WriteLine(stateNames[i] + Text.GetCharacter(9) + stateElectoralVotes[i] + Text.GetCharacter(9) + popularVotesForObama[i] + Text.GetCharacter(9) + popularVotesForMcCain[i])
    EndFor
    
    

    Sunday, November 25, 2012 11:46 PM

Answers

  • You just needed more tabulations { Text.GetCharacter(9) }.

    Also, I've saved all of the 4 arrays into 4 .txt files inside same folder as the program:

    stateNames.txt:

    1=Alabama  ;2=Alaska   ;3=Arizona  ;4=Arkansas;5=California;6=Colorado;7=Connecticut;8=D.C.        ;9=Delaware  ;10=Florida  ;11=Georgia  ;12=Hawaii   ;13=Idaho   ;14=Illinois  ;15=Indiana  ;16=Iowa    ;17=Kansas  ;18=Kentucky  ;19=Louisiana;20=Maine   ;21=Maryland ;22=Massachusetts;23=Michigan;24=Minnesota;25=Mississippi;26=Missouri;27=Montana  ;28=Nebraska;29=Nevada  ;30=New Hampshire;31=New Jersey;32=New Mexico;33=New York  ;34=North Carolina;35=North Dakota;36=Ohio    ;37=Oklahoma;38=Oregon   ;39=Pennsylvania;40=Rhode Island;41=South Carolina;42=South Dakota;43=Tennessee;44=Texas   ;45=Utah    ;46=Vermont  ;47=Virginia;48=Washington ;49=West Virginia;50=Wisconsin;51=Wyoming  ;

    stateElectoralVotes.txt:

    1=9;2=3;3=10;4=6;5=55;6=9;7=7;8=3;9=3;10=27;11=15;12=4;13=4;14=21;15=11;16=7;17=6;18=8;19=9;20=4;21=10;22=12;23=17;24=10;25=6;26=11;27=3;28=5;29=5;30=4;31=15;32=5;33=31;34=15;35=3;36=20;37=7;38=7;39=21;40=4;41=8;42=3;43=11;44=34;45=5;46=3;47=13;48=11;49=5;50=10;51=3;

    popularVotesForObama.txt:

    1=811764;2=111560;3=948648;4=418049;5=7441458;6=1216793;7=979316;8=210403;9=255394;10=4143957;11=1843452;12=324918;13=235219;14=3319237;15=1367503;16=818240;17=499979;18=751515;19=780981;20=421484;21=1612692;22=1891083;23=2867680;24=1573323;25=520864;26=1439940;27=229725;28=329132;29=531884;30=384591;31=2085051;32=464458;33=4363386;34=2123390;35=141113;36=2708685;37=502294;38=978605;39=3192316;40=296547;41=862042;42=170886;43=1093213;44=3521164;45=301771;46=219105;47=1958370;48=1548654;49=301438;50=1670474;51=80496;

    popularVotesForMcCain.txt:

    1=1264879;2=179424;3=1132560;4=632672;5=4554643;6=1020135;7=620210;8=14821;9=152356;10=3939380;11=2048244;12=120309;13=400989;14=1981158;15=1341667;16=677508;17=685541;18=1050599;19=1147603;20=296195;21=956663;22=1104284;23=2044405;24=1275400;25=687266;26=1444720;27=241816;28=448801;29=411988;30=316937;31=1545495;32=343820;33=2576360;34=2109698;35=168523;36=2501855;37=959745;38=699673;39=2586496;40=165389;41=1034500;42=203019;43=1487564;44=4467748;45=555491;46=98791;47=1726053;48=1098072;49=394278;50=1258181;51=160639;

    And now, here's the new code:

    'Election Results Parallel Arrays:
    TAB = Text.GetCharacter(9)
    LF  = Text.GetCharacter(10)
    
    path = Program.Directory + "\"
    ext  = ".txt"
    
    ' Load arrays from files:
    stateNames            = File.ReadContents( path + "stateNames"            + ext )
    stateElectoralVotes   = File.ReadContents( path + "stateElectoralVotes"   + ext )
    popularVotesForObama  = File.ReadContents( path + "popularVotesForObama"  + ext )
    popularVotesForMcCain = File.ReadContents( path + "popularVotesForMcCain" + ext )
    
    statesNumber = Array.GetItemCount(stateNames)
    
    'Display State-by-State result chart:
    TextWindow.WriteLine("State-by-State 2008 Election Results:" + LF)
    TextWindow.WriteLine("State" + TAB + TAB + "Electoral" + TAB + "Obama" + TAB + TAB + "McCain")
    TextWindow.WriteLine("=====" + TAB + TAB + "=========" + TAB + "=====" + TAB + TAB + "======")
    
    For i = 1 To statesNumber
      TextWindow.Write(stateNames[i] + TAB + stateElectoralVotes[i] + TAB + TAB)
      TextWindow.Write(popularVotesForObama[i] + TAB + TAB) 
      TextWindow.WriteLine(popularVotesForMcCain[i])
    EndFor

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Edited by GoToLoopEditor Monday, November 26, 2012 12:35 AM
    • Marked as answer by Rosco2382 Monday, November 26, 2012 1:20 AM
    Monday, November 26, 2012 12:32 AM
    Answerer