Announcement

Collapse
No announcement yet.

Help Using an array

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

  • Michael Mattias
    replied
    I was referring to substance, not form.

    Perhaps each column instead of "X" is supposed to be a "count" of occurences of that digit.

    But then I shouldn't have had mutiple lines, should I?

    (Among other things, I don't do Lotto. )

    MCM

    Leave a comment:


  • John Montenigro
    replied
    Originally posted by Michael Mattias View Post
    Code:
          0   1   2   3   4   5   6   7   8   9   
    725           2           7       5           
    154       9           2   1                   
    503   4           1       7                   
    555                       8
    ???
    OK, I'm baffled - I don't see how the numbers under the columns relate to the original question.

    If you go back to messages 1 and 7, and click on the Quote button - you'll see the proper spacing for what Lloyd was looking for.

    His messages don't make any sense in proportional font (without CODE tags) because the forum software compresses adjacent spaces, and the X X X indicators are way out of alignment. But you can see the alignment the way Lloyd saw it when he created the message, by examining it in the fixed font of the editor...

    -jhm

    Leave a comment:


  • Rodney Hicks
    replied
    You'd think, after 3 weeks straight of laughing, his tummy would start to hurt.
    Must be in a lot of pain, from May 3, 2000. His head may even be hurting. or was.

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Originally posted by Rodney Hicks View Post
    ..., at least someone is having a long laugh.
    You'd think, after 3 weeks straight of laughing, his tummy would start to hurt.
    =========================================
    When someone does something good,
    applaud!
    You will make two people happy.
    Samuel Goldwyn
    =========================================

    Leave a comment:


  • John Montenigro
    replied
    I had to tag the output as code so that the message would use fixed font, thereby preserving the character alignment. The forum software inserts that little "Code:" label.

    Leave a comment:


  • Michael Mattias
    replied
    Code:
          0   1   2   3   4   5   6   7   8   9   
    725           2           7       5           
    154       9           2   1                   
    503   4           1       7                   
    555                       8
    ???

    Leave a comment:


  • John Montenigro
    replied
    In between calls and emails this morning... (a slow day to be sure)

    Code:
    #COMPILE EXE
    #DIM ALL
    
    FUNCTION PBMAIN () AS LONG
    
       LOCAL i, j, Counter AS LONG, Header, temp, Num, Dig, m AS STRING
    
       Counter = 4
       DIM table(Counter) AS STRING
       table(1) = "11/15/2008 725"
       table(2) = "11/16/2008 154"
       table(3) = "11/17/2008 503"
       table(4) = "11/18/2008 555"
    
       Header = "   0   1   2   3   4   5   6   7   8   9   "
       PRINT SPACE$(3) & Header
    
       FOR i = 1 TO Counter
          temp = Header 'we're going to edit this to pieces
          Num = RIGHT$(table(i), 3)
          FOR j = 1 TO LEN(Num)
             Dig = MID$(Num, j, 1)
             REPLACE Dig WITH "X" IN temp
          NEXT j
          FOR j = 1 TO LEN(temp)
             Dig = MID$(temp, j, 1)
             IF Dig <> "X" AND Dig <> " " THEN
                MID$(temp, j, 1) = " "
             END IF
          NEXT j
          'm = m & Num & temp & $CRLF    'having trouble with this - CRLFs are being treated as chars, no action
          PRINT Num & temp '& $CRLF
       NEXT i
       '? m
    
       WAITKEY$
    END FUNCTION

    Outputs:

    Code:
          0   1   2   3   4   5   6   7   8   9   
    725           X           X       X           
    154       X           X   X                   
    503   X           X       X                   
    555                       X


    Now my question is: WHY?

    What good is this? I'm not a mathemetician, and I have a minimal knowledge of combinations and permutations... But if you're looking for distribution of digits in the daily Pick-3, aren't there better ways? This really doesn't reveal that in the fourth entry, the digit 5 occurred 3 times...

    Just asking...

    -jhm

    Leave a comment:


  • John Montenigro
    replied
    OK, so (picture Groucho with a cigar and raised eyebrow) here's the $64,000 question:

    Can anyone (and Lloyd, please feel free to jump in here) state in clear terms what Lloyd is trying to accomplish? Clear enough so that anyone who writes code for it (given the same inputs) will produce the same, identical output?

    I think we have not yet received enough information from Lloyd to accomplish that.

    AND, a simple place to start would be the end: if he could show us a sample of the desired output, and tell us the meaning of the elements in it, then this would be finished.

    AND!!! I'd put money on the fact that he's tried several times, but has been thwarted by not knowing about the use of CODE tags. His objective is a column formatted matrix, but he's tried to show us in messages that compress spaces in a proportional font. If he'd started out using the appropriate font, I'd bet we'd be a lot farther along with this.

    Hmm.. Presuming his second message still has the spacing he intended, I'm going to try copying it and see what it looks like...

    Code:
    (first message)
    
    
    ...
    (second message)
    
    I have a list of dates and values example xx/xx/xxxx 725
    I want to spred the 725 into an array consisting of 0 1 2 3 4 5 6 7 8 9
    spred like this x x x
    there are approx 31 enteries in the list
    Can anyone tell me how to do this????
    OK, so that was creative, but I previewed it and it didn't work... I think I'd have to quote his message, not just copy it. That will take extra work... be back with another try soon...

    Back with another try:

    Originally posted by Lloyd Plantholt View Post
    I have a table I would like to split out.
    Example:
    Code:
                      11/15/2008    725
                      11/16/2008    154
                      11/17/2008    503
    I would like to spred the numbers 725,154,503 into 10 array slots, each having
    Code:
                0  1  2  3  4   5  6  7   8   9  
         725          X         X     X
         154       X        X   X
         503    X        X      X
    Once I have them spred I want to print the array
    How's that?



    By the way, notice that Lloyd didn't mention anything about what's wanted when the input number has duplicate digits...

    eg: 121, 505, 441, 555, etc.

    Would the X under that column be sufficient?

    Or is there some rule that prevents the input numbers from having duplicates?

    ...just wondering... guessing... imagining... wasting time...

    -jhm
    Last edited by John Montenigro; 4 Dec 2008, 09:33 AM. Reason: C&P from a quote of the Lloyd's message, added CODE tags

    Leave a comment:


  • John Montenigro
    replied
    Originally posted by Chris Holbrook View Post
    No, with a clear OBJECTIVE (and some money, but that's another story!). Specifications of requirements and work are developed later and their ownership, though as you hinted, not necessarily their authorship is critical to the progress of the project.
    I agree. I didn't explicitly state the pre-requisite for Objective and Budget, because I was framing the discussion around the program, which I would expect only follows the having of an Objective and Budget, and schedule, staff, tools, etc.

    Leave a comment:


  • John Montenigro
    replied
    Originally posted by Cliff Nichols View Post
    ...
    Seen it allllll too often, and unfortunately I can not change physics, but if I could then the consultant (or who-ever comes up with the specs) would have had a past life experience in the trenches as a programmer and know better what is feasible and not feasible
    Ooooooo... that's not a ringing endorsement for consultants! The kind you describe make my skin crawl.

    More than being on the gravy train, I've always been more concerned with delivering good products.

    I bring the users, the managers, and the technicians together in their agreement on what is to be built. I see it as my primary responsibility. The building and the implementation are easy if the communications are in good shape.

    But maybe that's because I've had experience in the trenches.

    Leave a comment:


  • Cliff Nichols
    replied
    But seriously, every project ought to start with clear specs, regardless of who puts them together.
    Agreed....But how often do the specs come from "Well I was tasked with this, and here is what I want" (not knowing fully what they want), and later argue that it is NOT spot on??? (again a good thing for the argument of "Do NOT sign Off until satisfied" vs keeping customers satisfied without the hassel of "Horseshoes vs HandGrenades"

    the difference between a 'contractor' and a 'consultant.'
    Typically the "Contractor" does as told...even if its wrong. (Reputable ones argue when the KNOW its wrong, but may cave to pressure)

    "Consultant" is basically the "Yes Man" and will deliver anything from the moon and beyond (whether its really possible or not within the scope of what needs to be done)

    For lack of rudeness I consider a consultant as a middle to high management guy that offers the moon, and unfortunately for the "Grunt" that has to do the work it is his problem if not 100% matching (and getting 3rd party information from the get-go)

    Seen it allllll too often, and unfortunately I can not change physics, but if I could then the consultant (or who-ever comes up with the specs) would have had a past life experience in the trenches as a programmer and know better what is feasible and not feasible

    Leave a comment:


  • Michael Mattias
    replied
    >ability to clearly express in plain English the desired output and logic of your program."

    Much as I would like to see that as well, it's been my experience that few can do that. But if they can FOLLOW ...
    Good point.

    Maybe that's the difference between a 'contractor' and a 'consultant.'

    MCM

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by John Montenigro View Post
    But seriously, every project ought to start with clear specs, regardless of who puts them together.
    No, with a clear OBJECTIVE (and some money, but that's another story!). Specifications of requirements and work are developed later and their ownership, though as you hinted, not necessarily their authorship is critical to the progress of the project.

    Leave a comment:


  • Rodney Hicks
    replied
    Gösta,
    If you're right, at least someone is having a long laugh.

    Leave a comment:


  • John Montenigro
    replied
    Originally posted by Michael Mattias View Post
    ...

    (Note to self for list of Top Ten Things You Need to be an Effective Programmer: "ability to clearly express in plain English the desired output and logic of your program.")

    MCM
    Much as I would like to see that as well, it's been my experience that few can do that. But if they can FOLLOW and BUILD the logic that is specified for them, then you're not demanding something unlikely.

    OK, I admit, I have an interest in letting programmers program... Originally a Technical Writer, then Systems Analyst, and currently a certified Business Analyst, you hire me to pick your brain and express the requirements in clear language... the old "Vulcan Mind Meld", it's what I do.

    But seriously, every project ought to start with clear specs, regardless of who puts them together.


    Gosta,

    "For those confused by Lloyd's request for array help, maybe this will help"
    I went to the link you provided. Now I'm headed to the refrigerator. You gots to start with a clear goal.
    Last edited by John Montenigro; 3 Dec 2008, 01:10 AM. Reason: replaced a lot of sarcasm with a some philosophy and a tiny bit of humor

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    For those confused by Lloyd's request for array help, maybe this will help: http://www.powerbasic.com/support/pb...read.php?t=220 . Apparently he's been working on this problem for quite some time.

    =========================
    Of two evils
    always choose the least.
    Thomas a Kempis
    =========================

    Leave a comment:


  • Michael Mattias
    replied
    >I'm sorta gettin the feelin Lloyd is playing with us, boys

    I don't get that, and I'm hardly on the short list for the Nobel Prize in Sensitivity.

    Looking at last code (the one with the compile error).....

    Is ary() supposed to be a frequency table? ie, ary(8) is the number of occurences of '8' in the input file?

    (Note to self for list of Top Ten Things You Need to be an Effective Programmer: "ability to clearly express in plain English the desired output and logic of your program.")

    MCM

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    I'm sorta gettin the feelin Lloyd is playing with us, boys.

    =====================================================
    The random nature of quantum physics
    means that there is always a minuscule, but nonzero,
    chance of anything occurring,
    including that the new collider could spit out
    man-eating dragons.
    NY Times article on the Large Hadron Collioder
    =====================================================

    Leave a comment:


  • Rodney Hicks
    replied
    Not sure which compiler you are using. The following was done in PBWin 9.0.

    Code:
    #COMPILE EXE
    #DIM ALL
    
    FUNCTION PBMAIN () AS LONG
      LOCAL ary(),nr1,nr2,nr3,temp,cntr AS LONG
      LOCAL dteS, dtaS AS STRING    'removed the type specifier and replaced it with S to indicate string
      DIM ary(1 TO 3)
    
    
      OPEN "lotbase.txt" FOR INPUT AS #1
      OPEN "lotout.txt" FOR OUTPUT AS #2
    
      DO WHILE NOT EOF(1)
        INCR cntr
        LINE INPUT #1, dtaS
    
        dteS = (MID$(dtaS,1,10))
        nr1 = VAL(MID$(dtaS,12,1))   '
        nr2 = VAL(MID$(dtaS,16,1))
        nr3 = VAL(MID$(dtaS,20,1))
    
        ary(1) = nr1 '<
        ary(2) = nr2 '<----- this should work
        ary(3) = nr3 '<
    
        PRINT #2, dteS;" ";ary(1)," ",ary(2)," ",ary(3)    'I don't really think this is what you want so comment it out and uncomment
        'temp=(ary(1)*100)+(ary(2)*10)+ary(3)              'these two lines
        'PRINT #2, dteS;" ";temp
        
      LOOP
      CLOSE #1
      CLOSE #2
    END FUNCTION
    This does not spread the numbers out in any fashion, but it does gather them to what you were doing as best I could figure out from your last post.

    Leave a comment:


  • Michael Mattias
    replied
    ary,nr1 = nr1 <
    ary,nr2 = nr2 <----- this does not work
    ary,nr3 = nr3 <
    ==>
    Code:
    ary(nr1) = nr1
    ary(nr2) = nr3
    ary(nr3) = nr3
    See also: http://www.powerbasic.com/support/pb....php?do=bbcode

    Using code tags makes it MUCH easier to read on-line.

    Leave a comment:

Working...
X