Return to “Announcements”

Post

Re: The End

#301
Still keen on the idea of something like github so that there is a version to download and a place for the community to work together to fine tune/debug it as needed. Github now has free private project pages, if you still wanted to limit it to backers and the original devs.
Post

Re: The End

#307
Silverware wrote:
Wed Jun 12, 2019 5:22 pm
IronDuke wrote:
Wed Jun 12, 2019 5:20 pm
it can't possible be messier than Silver's code :ghost:
Yes, it can. You haven't seen other peoples code. Mine... is relatively tidy.

Those of you with weak constitutions may wish to avert your eyes from the chthonic horror that is the Super Star Trek code written in PL/I as I last updated it in 1985:

Code: Select all

      ROMULN: PROC(E);
      IF RX=0 THEN RX=1;
      IF RY=0 THEN RY=1;
       H=(1000+500*RND)/SQRT((S1-RX)**2+(S2-RY)**2);
      IF C$='DOCKED' THEN DO;
        PUT EDIT('STARBASE SHIELDS PROTECT ',N$,' FROM ROMULAN')
          (COL(1),A,A,A); GOTO MOVER; END;
        IF Z$='UP' THEN DO; A9=A9-H;
      IF A9>0 THEN DO;
     PUT EDIT('SHIELDS PROTECT ',N$,' FROM ROMULAN')(COL(1),A,A,A);
      GOTO MOVER; END;
      H=-A9; Z$='DOWN';
      PUT SKIP LIST('ROMULAN ATTACK CRASHES SHIELDS'); END;
    E=E-H;PUT EDIT(H,' HIT ON ',N$,' FROM ROMULAN AT SECTOR ',RX,'-',RY)
      (COL(1),F(6,1),A,A,A,F(2),A,F(2));
      IF E<=0 THEN DO; P4=10; CALL #11950; GOTO #6930; END;
      IF E<=100 THEN DO; P4=11; CALL #11950; END;
      /* MOVE ROMULAN AT RANDOM */
    MOVER: PUT EDIT('ROMULAN AT ',RX,'-',RY,' MOVES.') (COL(1),A,F(2),A,F(
     2),A);
      Q(RX,RY)=0; RW=.3*RND+.1; RD=360*RND;
      RX1=-COS(RD/57.296); RY1=SIN(RD/57.296);
      DO I=1 TO TRUNC(RW*10.05); RX=RX+RX1; RY=RY+RY1;
      IF Q(TRUNC(RX+.5),TRUNC(RY+.5))¬=0 THEN GOTO HOLDIT;
      END;
      ROMSTP: RX=TRUNC(RX+.5) RY=(TRUNC(RY+.5); GOTO ROMOVE;
      HOLDIT: RX=RX-RX1; RY=RY=RY1; GOTO ROMSTP;
      ROMOVE: Q(RX,RY)=7; RD=45*TRUNC(RD/45+.5);
    PUT SKIP LIST('SENSORS INDICATE ROMULAN IS MOVING APPROXIMATELY');
      PUT EDIT('ON COURSE ',RD,' AT WARP ',RW)
        (COL(1),A,F(3),A,F(3,1));
      RETURN; END;

And that's a relatively sane section. There's no way Silver's code -- or Josh's -- is this bad.

...yay?
Post

Re: The End

#308
Flatfingers wrote:
Thu Jun 13, 2019 12:00 am
Silverware wrote:
Wed Jun 12, 2019 5:22 pm
IronDuke wrote:
Wed Jun 12, 2019 5:20 pm
it can't possible be messier than Silver's code :ghost:
Yes, it can. You haven't seen other peoples code. Mine... is relatively tidy.

Those of you with weak constitutions may wish to avert your eyes from the chthonic horror that is the Super Star Trek code written in PL/I as I last updated it in 1985:



And that's a relatively sane section. There's no way Silver's code -- or Josh's -- is this bad.

...yay?
Snip'd with <3

Wow, is there moar?
YAY PYTHON \o/

In Josh We Trust
-=326.3827=-
Post

Re: The End

#310
Just to show how my code looks when being written for a production environment.
Spoiler:      SHOW

Code: Select all

args=""
if [ -n "${MASTER}" ]; then args="${args} -S ${MASTER}"; fi
if [ -n "${CLIENT}" ]; then args="${args} -C ${CLIENT}"; fi
if [ -n "${POLICY}" ]; then args="${args} -k ${POLICY}"; fi
if [ -n "${POLICYTYPE}" ]; then args="${args} -t ${POLICYTYPE}"; fi
if [ -n "${AFTER}" ]; then args="${args} -s ${AFTER}"; fi
if [ -n "${BEFORE}" ]; then args="${args} -e ${BEFORE}"; fi
if [ -n "${NOCLOBBER}" ]; then args="${args} -K"; fi
## Start Restore of File(s)
if [ -z "${FILELIST}" ]; then
	log "Restore Started for ${FILE}"
	${BPRESTORE} ${args} -L ${TMPFILE} -w ${FILE}
	# '-w' is used so that this sciprt will only move on ONCE the file has finished (or failed) restoring
	RET=$?
	log "Restore Finished for ${FILE}"
else
	# Rename only works as a filelist, so we include the feature here
	if [ -n "${RENAME}" ]; then args="${args} -R ${RENAME}"; fi
	log "Restore Started for Multiple Files"
	${BPRESTORE} ${args} -L ${TMPFILE} -w -f ${FILELIST}
	# '-w' is used so that this sciprt will only move on ONCE the file has finished (or failed) restoring
	RET=$?
	log "Restore Finished for Multiple Files"
fi
So that you can see the difference.
°˖◝(ಠ‸ಠ)◜˖°
Image
qRogue v0.0.9
Post

Re: The End

#312
zircher wrote:
Thu Jun 13, 2019 6:58 pm
Comments are for the weak. :-)

"If it was hard to write, it should be hard to understand, and even harder to modify." :D

FormalMoss wrote:
Thu Jun 13, 2019 5:33 am
Wow, is there moar?

There's considerably more. That snippet, plus all the other spaghetti code (some of which is even worse), is what I found in the Chemical Engineering section of the campus mainframe back in 1982. All I did -- then -- was some bug-fixing, but I didn't change any of the basic structure from the original PL/I code (which itself had been adapted, presumably, from the even more original version written in BASIC).

It was a bit of a challenge to figure out that gibberish and convert it to JavaScript a few years ago. One of these days I might fork a version to which I can add more features ("Super-Duper Star Trek"?)...

...but this is now very off-topic.
Post

Re: The End

#313
Talvieno wrote:
Tue Jun 11, 2019 9:20 am
I get the feeling he's wanting the source code to be "perfectly tidy" when he releases it... which isn't really necessary.
Reminds me of this:
We've been meaning to release all this for ages, in various forms, and always ended up not doing it because "we'd just have to clean it up a bit first...".
Better not let that happen - just wrangle it through a code sanitizer and start uploading to gitlab or whatever. Look at file, add, push. Repeat until it is done. Best way of going about this IMO.
Post

Re: The End

#314
Silverware wrote:
Thu Jun 13, 2019 7:26 pm
Just to show how my code looks when being written for a production environment.
Spoiler:      SHOW

Code: Select all

args=""
if [ -n "${MASTER}" ]; then args="${args} -S ${MASTER}"; fi
if [ -n "${CLIENT}" ]; then args="${args} -C ${CLIENT}"; fi
if [ -n "${POLICY}" ]; then args="${args} -k ${POLICY}"; fi
if [ -n "${POLICYTYPE}" ]; then args="${args} -t ${POLICYTYPE}"; fi
if [ -n "${AFTER}" ]; then args="${args} -s ${AFTER}"; fi
if [ -n "${BEFORE}" ]; then args="${args} -e ${BEFORE}"; fi
if [ -n "${NOCLOBBER}" ]; then args="${args} -K"; fi
## Start Restore of File(s)
if [ -z "${FILELIST}" ]; then
	log "Restore Started for ${FILE}"
	${BPRESTORE} ${args} -L ${TMPFILE} -w ${FILE}
	# '-w' is used so that this sciprt will only move on ONCE the file has finished (or failed) restoring
	RET=$?
	log "Restore Finished for ${FILE}"
else
	# Rename only works as a filelist, so we include the feature here
	if [ -n "${RENAME}" ]; then args="${args} -R ${RENAME}"; fi
	log "Restore Started for Multiple Files"
	${BPRESTORE} ${args} -L ${TMPFILE} -w -f ${FILELIST}
	# '-w' is used so that this sciprt will only move on ONCE the file has finished (or failed) restoring
	RET=$?
	log "Restore Finished for Multiple Files"
fi
So that you can see the difference.
Pretty reasonable. Assuming it's being run on a vaguely-recent bash, I would suggest some changes:
  • Construct `args` by appending to an indexed array, not a string, like:

    Code: Select all

    args = (); args+=("-S" "${MASTER}")
  • Then, when calling `BPRESTORE`, expand `args` as an array to ensure each item is passed as a separate arg, like:

    Code: Select all

    ${BPRESTORE} "${args[@]}" ... 
  • Double-quote the other arguments you pass to `BPRESTORE`; even if you know a priori that they do not contain spaces or globs, that may no longer be true after you or someone else edits the script later, so you're still better off quoting them to prevent possible unexpected behaviour in the future.
  • The combination of those three changes clarifies the intent of the code, and prevents unexpected word-splitting changing what should be a single argument token into multiple tokens.
  • Start using shellcheck. Ideally, with editor integration.
Post

Re: The End

#315
Shados wrote:
Sun Jun 16, 2019 8:03 pm
Silverware wrote:
Thu Jun 13, 2019 7:26 pm
Pretty reasonable. Assuming it's being run on a vaguely-recent bash, I would suggest some changes:
  • Construct `args` by appending to an indexed array, not a string, like:

    Code: Select all

    args = (); args+=("-S" "${MASTER}")
  • Then, when calling `BPRESTORE`, expand `args` as an array to ensure each item is passed as a separate arg, like:

    Code: Select all

    ${BPRESTORE} "${args[@]}" ... 
  • Double-quote the other arguments you pass to `BPRESTORE`; even if you know a priori that they do not contain spaces or globs, that may no longer be true after you or someone else edits the script later, so you're still better off quoting them to prevent possible unexpected behaviour in the future.
  • The combination of those three changes clarifies the intent of the code, and prevents unexpected word-splitting changing what should be a single argument token into multiple tokens.
  • Start using shellcheck. Ideally, with editor integration.
First (and only post) since 2012. Good job Silverware, you catched a lurker here using only your tidy code.
More people want exploding kittens than exploding ships. Somehow, this makes me happy.
- credits go to dwmagus

Online Now

Users browsing this forum: Baidu [Spider] and 0 guests

cron