• Solved my Program issues...

    From Black Panther@21:1/186 to All on Thu Feb 15 20:11:14 2018
    Hi All,

    There have been a couple times in the last two weeks, where my nightly events seemed to freeze. This caused any other events to not run until I notice the issue. This would happen with the program I wrote to generate the joke posting.

    Over these last two weeks, I had been trying to figure out what was happening to cause that program to stop working. Well I finally got it working.

    The program keeps a text file with the joke numbers that have already been posted. I had a procedure to generate a random number, and then check it with the text file. If it existed, it would generate another random number, etc.

    Well, after a set number of times, it would eventually exit out of the procedure with a message on the screen stating "All available jokes have been posted".

    Someone must have been playing around with my code, because the next line was:

    readln; //this command waits for the user to hit enter

    I know I wouldn't have put that in there... ;) It seems to be working fine now...

    <facepalm> ;)


    ---

    Black Panther
    a.k.a. Dan Richter
    Sysop - Castle Rock BBS (RCS)
    telnet://bbs.castlerockbbs.com
    http://www.castlerockbbs.com
    The sparrows are flying again....

    --- Mystic BBS v1.12 A38 2018/01/01 (Linux/64)
    * Origin: Castle Rock BBS - bbs.castlerockbbs.com (21:1/186)
  • From apam@21:1/125 to Black Panther on Fri Feb 16 13:15:14 2018
    I know I wouldn't have put that in there... ;) It seems to be working
    fine now...

    Woo! It's a nice feeling when you squash a bug that's been hanging around
    a while :)

    Andrew


    --- MagickaBBS v0.10alpha (Linux/x86_64)
    * Origin: Exotica BBS - telnet://exoticabbs.com:2023/ (21:1/125)
  • From Black Panther@21:1/186 to apam on Thu Feb 15 20:29:22 2018
    On 02/16/18, apam said the following...

    I know I wouldn't have put that in there... ;) It seems to be working fine now...

    Woo! It's a nice feeling when you squash a bug that's been hanging around a while :)

    It sure does... I just can't believe I would have put that in there... :)


    ---

    Black Panther
    a.k.a. Dan Richter
    Sysop - Castle Rock BBS (RCS)
    telnet://bbs.castlerockbbs.com
    http://www.castlerockbbs.com
    The sparrows are flying again....

    --- Mystic BBS v1.12 A38 2018/01/01 (Linux/64)
    * Origin: Castle Rock BBS - bbs.castlerockbbs.com (21:1/186)
  • From apam@21:1/125 to Black Panther on Fri Feb 16 13:36:28 2018
    It sure does... I just can't believe I would have put that in
    there... :)

    Hehe, don't worry you're not alone. I've had my share of "what the hell
    was I thinking" moments :)

    Andrew

    --- MagickaBBS v0.10alpha (Linux/x86_64)
    * Origin: Exotica BBS - telnet://exoticabbs.com:2023/ (21:1/125)
  • From NIA01@21:2/108 to Black Panther on Fri Feb 16 09:20:18 2018
    Well, after a set number of times, it would eventually exit out of the procedure with a message on the screen stating "All available jokes have been posted".

    Looks like the joke was on you :)

    National Incident Alerts
    telnet://niabbs.com
    www.nationalincidentalerts.com

    --- Mystic BBS v1.12 A35 (Windows/32)
    * Origin: NIA BBS (21:2/108)
  • From tenser@21:1/112 to Black Panther on Fri Feb 16 09:54:10 2018
    Something that may help:

    Many of you are writing code in Free Pascal. Find a unit testing framework
    for it and learn how to use it well, then get into the habit of writing tests for your code. Also, start using a revision control system if you don't
    already and get into the habit of making lots of small commits.

    Much of the, "I put a getc(); or readln; into my program so I can see what
    was happening at that point in the code" is for debugging purposes. I get it; I've been there too (I develop kernels for a living so you better believe I pepper code with a bunch of, `asm volatile("HLT;":::);` in various places so
    I can figure out what's faulting and why). But getting into the unit testing discipline gets rid of the need for most of it, and the revision control
    system makes it easy to back that stuff out and get back to a known-working state.

    Hope that helps!

    --- Mystic BBS v1.12 A38 2018/01/01 (Windows/32)
    * Origin: ACiD Telnet HQ / blackflag.acid.org (21:1/112)
  • From Black Panther@21:1/186 to NIA01 on Fri Feb 16 17:15:14 2018
    On 02/16/18, NIA01 said the following...

    Well, after a set number of times, it would eventually exit out of th procedure with a message on the screen stating "All available jokes h been posted".

    Looks like the joke was on you :)

    Lol. Yes it was... :)


    ---

    Black Panther
    a.k.a. Dan Richter
    Sysop - Castle Rock BBS (RCS)
    telnet://bbs.castlerockbbs.com
    http://www.castlerockbbs.com
    The sparrows are flying again....

    --- Mystic BBS v1.12 A38 2018/01/01 (Linux/64)
    * Origin: Castle Rock BBS - bbs.castlerockbbs.com (21:1/186)
  • From Black Panther@21:1/186 to tenser on Fri Feb 16 17:31:44 2018
    On 02/16/18, tenser said the following...

    Many of you are writing code in Free Pascal. Find a unit testing
    framework for it and learn how to use it well, then get into the habit

    I didn't even know that was an option until I read this... I've looked it up, and it seems that Lazarus already has a couple of options available. I'll be doing some looking into that. Thanks.

    of writing tests for your code. Also, start using a revision control system if you don't already and get into the habit of making lots of
    small commits.

    Revision control I have been doing. On the other hand, I have a tendency make commits that are a lot larger, and contain many additions/changes. I really should stop that...

    Much of the, "I put a getc(); or readln; into my program so I can see
    what was happening at that point in the code" is for debugging purposes.

    I find myself doing that a lot. I'll have it writeln what is contained in the variables to the screen, and then put a readln, so I can read it.

    I get it; I've been there too (I develop kernels for a living so you better believe I pepper code with a bunch of, `asm volatile("HLT;":::);` in various places so I can figure out what's faulting and why). But

    That has got to be an interesting and sometimes frustrating job. :)

    getting into the unit testing discipline gets rid of the need for most
    of it, and the revision control system makes it easy to back that stuff out and get back to a known-working state.

    Do you think using something like github would be a good idea for revision control? Or do you think just copies on the hard drive, and figuring out
    which .PAS file is which, would be sufficient? :)

    Hope that helps!

    It really does. Thank you.


    ---

    Black Panther
    a.k.a. Dan Richter
    Sysop - Castle Rock BBS (RCS)
    telnet://bbs.castlerockbbs.com
    http://www.castlerockbbs.com
    The sparrows are flying again....

    --- Mystic BBS v1.12 A38 2018/01/01 (Linux/64)
    * Origin: Castle Rock BBS - bbs.castlerockbbs.com (21:1/186)
  • From tenser@21:1/112 to Black Panther on Fri Feb 16 20:56:56 2018
    On 02/16/18, Black Panther said the following...

    On 02/16/18, tenser said the following...

    Many of you are writing code in Free Pascal. Find a unit testing framework for it and learn how to use it well, then get into the habi

    I didn't even know that was an option until I read this... I've looked
    it up, and it seems that Lazarus already has a couple of options available. I'll be doing some looking into that. Thanks.

    That's great! It forces a different way of programming, but once
    you get the hang of it you'll wonder how you ever did things before.

    of writing tests for your code. Also, start using a revision control system if you don't already and get into the habit of making lots of small commits.

    Revision control I have been doing. On the other hand, I have a tendency make commits that are a lot larger, and contain many additions/changes.
    I really should stop that...

    It takes a while to get into the habit, but once you've got it down
    it's handy. In general, you should structure the history of your commits
    as if you were telling a story. Coupled with good commit messages,
    you'll rarely run into the, "what the hell was I thinking six months
    ago?!" thing.

    Much of the, "I put a getc(); or readln; into my program so I can see what was happening at that point in the code" is for debugging purpos

    I find myself doing that a lot. I'll have it writeln what is contained
    in the variables to the screen, and then put a readln, so I can read it.

    Hey, that's fine: I totally get it. Sometimes it's the best way. When
    you're doing iterative development, it can make a lot of sense: you
    write something, you get it to the point where you think it's more or
    less doing what you want, you print some output so you can inspect
    state at that point, and then you move on. It's not a BAD way to do
    things, but there are other ways that are better (writing lots of unit
    tests) if you can get your code into the shape that it admits that kind
    of testing.

    This is also handy because those tests are easily repeatable: You make
    some change, and if you run the tests again and they all pass (and you've
    got good test coverage) then you can move forward under the reasonable assumption that you haven't broken anything. On the other hand, if the
    tests fail, then you've got something you can look at to help you
    troubleshoot what went wrong. If you couple that with relatively small
    commits, it's often fairly easy to find the problem.

    I get it; I've been there too (I develop kernels for a living so you better believe I pepper code with a bunch of, `asm volatile("HLT;"::: in various places so I can figure out what's faulting and why). But

    That has got to be an interesting and sometimes frustrating job. :)

    Yeah, it's interesting but it can be really frustrating. Here's an example
    of something I found recently that was a pain: I had a small microhypervisor we're investigating that came out of a research project. The code is sort
    of like the Fisher Price, "Grad Student's First C++ Program": overusing esoteric language features because they're cool; that kind of thing. Anyway, most of the time these things start by having a bootloader jump to some
    known entry point that you hand-code in assembler: this gets paging enabled, gets the machine into 64-bit mode (this is an x86_64 platform), sets up the language runtime environment and then jumps to the high-level language entry point (e.g., the `main` function). Only the thing was boot-looping due to an unhandled fault in the early startup code. Through judicious use of the HLT instruction through assembler, I was able to run it under QEMU and a debugger and find that it was dying on an invalid instruction (a left-shift that preserves condition codes; introduced in Haswell, but I was running it on
    an older microarchitecture). Oops. I changed the compiler flags to emit code for an older platform (core2) and it magically started working. Because my changes were minimal, I could just `git checkout file.cpp` to revert them.
    Yay revision control.

    getting into the unit testing discipline gets rid of the need for mos of it, and the revision control system makes it easy to back that stu out and get back to a known-working state.

    Do you think using something like github would be a good idea for
    revision control? Or do you think just copies on the hard drive, and figuring out which .PAS file is which, would be sufficient? :)

    Sure, github is fine, but github is a repository hosting service. For a
    SCM like git, which is a *distributed* version control system, you've
    already got a repository locally. Github is great because it lets you
    publish your work and collaborate with other programmers, but it's not necessary. The work flow is usually that you clone the repo on github
    into a local repo, edit, commit, amend, and generally make changes to your local clone, then push those to a branch on github (or, if it's a personal project, you can push to your own `master` branch).

    As far as specific revision control systems, `git` is quickly becoming
    a standard. Mercurial is also nice; stay away from Subversion, Perforce,
    CVS, RCS, SCCS, or any of the proprietary systems (Source Safe or whatever Microsoft's offering is). Such centralized or file-based VCS's are going
    the way of the dodo.

    Hope that helps!

    It really does. Thank you.

    Great! I'm happy to hear it.

    --- Mystic BBS v1.12 A38 2018/01/01 (Windows/32)
    * Origin: ACiD Telnet HQ / blackflag.acid.org (21:1/112)