• can't think of any more stupid names (unregistered)

    Loop? Come on get real, a subroutine would be nice.

  • LCrawford (unregistered)

    It wasn't just the looping that the original coder hadn't learned.

    begin
    'ToDo - How to assign sctevarS1Name, sctevarS2Name, etc in a loop end

  • (nodebb)

    I'm ... puzzled ... by the mixing of calls to Concat and + for string concatenation...

  • (nodebb) in reply to can't think of any more stupid names

    a subroutine would be nice.

    No, this is Pascal, so it would have to be a procedure.

    ;)

  • MRAB (unregistered)

    There are also, it appears, a field called 'txtname' and a field called 'txtsname'. I'm sure that's not a bug magnet.

  • JC (unregistered)

    The dreaded "for-case" pattern would be pretty adequate here.

  • (nodebb)

    Good jorb, guys! You are really worth your dollar per line of codez. Thanks!

  • network_noadle (unregistered)

    Ideal use case for a for...case structure, no?

  • Bart (unregistered)

    Also nice: use Concat() to concatenate strings, but inside the call to Concat() use "+" to concatenate strings.

  • Gearhead (unregistered)

    What does "Next" do in Pascal? Also EOF needs a file descriptor, that must be the WTF.

  • Hans van Dongen (unregistered) in reply to Gearhead
    Comment held for moderation.
  • I dunno LOL ¯\(°_o)/¯ (unregistered)
    Comment held for moderation.
  • Tim (unregistered) in reply to Gearhead

    This (especially the Next statement doesn't look like pascal (or any kind of sensible language) to me. It presumably reads a new record from some file into some global variable that is then accessed by the FieldsByName function. if this is the case then this implicit state held in a global variable would be more of a WTF than the code repetition

  • Kleyguerth (github) in reply to Gearhead

    It looks like this is inside a "With" block. "FieldByName", "Next" and "EOF" are probably part of the object that has been "With"ed.

  • Bart (unregistered) in reply to Kleyguerth
    Comment held for moderation.
  • (nodebb) in reply to Kleyguerth

    It looks like this is inside a "With" block. "FieldByName", "Next" and "EOF" are probably part of the object that has been "With"ed.

    There's no reason to assume that, given that there are no traces of the With itself. Most likely they are just procedures, either at the top level or nested at the same level as this code.

    Um.

    Procedures that operate on global variables, naturally, since there's no trace of the parameters necessary to make them work correctly otherwise.

    And EOF is a built-in part of Pascal, a function that returns true if the file it is given (standard input if no parameter is given) is at end-of-file.

    Note to all readers who haven't ever had reason to work with Pascal: if a function or procedure does not take parameters, when you call it, you do not pass an empty ().

  • Bart (unregistered) in reply to Steve_The_Cynic
    Comment held for moderation.
  • ZZartin (unregistered)

    Not really that bad, it looks like each block is setting a different higher scoped variable. So a loop would either have code that looks like if itor = 1 set var1 etc.... or everything would have to be refactored to push to an array of some kind.

  • Anonymous (unregistered) in reply to MRAB
    Comment held for moderation.
  • Anonymous (unregistered) in reply to Steve_The_Cynic
    Comment held for moderation.
  • Anonymous (unregistered) in reply to Gearhead
    Comment held for moderation.
  • Steve123 (unregistered)

    Missing punchline: so Andrew reviewed the commit logs, and found that he actually wrote this himself - in is first week in the job.

  • Tigger Dad (unregistered)

    I'm just looking forward to seeing what happens on the day when they have five sellers. Maybe they'll turn one away...

  • (nodebb) in reply to Steve_The_Cynic

    Note to all readers who haven't ever had reason to work with Pascal: if a function or procedure does not take parameters, when you call it, you do not pass an empty ().

    That allows some nice things, like defining something that behaves like a global constant but initializes itself on first use.

    Sadly, it also allows for ugly things like things that look like a constant but actually change or depend on mutable global state...

  • abidulla dafadar (unregistered)
    Comment held for moderation.
  • (nodebb) in reply to Kleyguerth

    It looks like this is inside a "With" block. "FieldByName", "Next" and "EOF" are probably part of the object that has been "With"ed.

    Unless we're looking at Object Pascal or a lookalike (Turbo>4, Delphi, ...), there are no "Objects" in Pascal. FieldByName looks like a function, and AsString is possibly a field in a record?

    Addendum 2022-10-25 03:45: After another look, it can't be a record. Looks like this is not regular Pascal, but some kind of ObjectPascal after all.

  • MaxiTB (unregistered) in reply to nerd4sale

    It's Delphi.

    The WTF is here that a dev instead of using an array started copy&paste hacks because to lazy for refactoring? Nothing special to see really.

  • fred weigel (unregistered)
    Comment held for moderation.
  • fred weigel (unregistered)
    Comment held for moderation.
  • Donald Klopper (google)

    FieldbyName indicates Delphi dataset / data aware components.

    And the code snippet hides the even more ugly "with" construct. Probably a programmer that predates "modern" Delphi (thus learned Pascal before 1995). I don't think it's my code ;-)

    Looks like programming by copy and paste ... and it just grew over time. Don't touch old code, just add new code blocks. GIT / SVN / VSS will be very happy about that.

  • (nodebb)

    Pity we couldn't do that, for some reason

    The reason is

    sctevarS3Name.AsString := lsSName;
    

    Each record has a unique name. Either sctevarS1Name, sctevarS2Name , sctevarS3Name or sctevarS4Name. If only Pascal had some way of subscripting variables, something like

    sctevarSName.AsString[i] := lsSName;
    

Leave a comment on “Four Sellers”

Log In or post as a guest

Replying to comment #584502:

« Return to Article