This was from the best episode of that entire series in a rare instance of the writers not trying to shoehorn a helicopter dogfight into an otherwise mundane domestic misadventure (assuming you're willing to accept that a helicopter can fly above the atmosphere and attempt to start WWIII of course).
Didn’t the same thing happen in Superman III? I seem to recall a computer display is shown with various advanced-looking outputs and then they also run a LIST command, which lists a BASIC (or maybe COMAL) program written to… display various advanced-looking outputs. Using the PRINT statement. Followed by many individual lines of PRINT "" to make the screen clear.
Iron Man (2008) shows that Iron Man boots with the Mozilla JavaScript documentation. It seems to favor RegExp. Maybe that was shoddy movie research, maybe we should be glad that Iron Man does not run on W3Schools tutorials, maybe Jeff Atwood is right when he said: any application that can be written in JavaScript, will eventually be written in JavaScript.
This made me remember the code from Vivek Ramachandran being used in the movie White House Down and him writing a blog post about it including the quirks in the code[0]
The overzealous headline-fixer strikes again. I can't remember what it was this morning, but it was better than this. The name of the blog an article is posted on is not an accurate or useful headline when the link only references a single article on that blog.
Source Code in TV and Films: There's
a bug in AirWolf's code ...
As you say, better than the generic title now.
I can understand why the moderators change a lot of the titles, I really can. And I can understand that it's potentially too time consuming to vet every single title that gets submitted, and hence it kind of needs to be automatic. But I really can't help thinking that on a forum called "Hacker News" there would be some kind of hack that says: Hang on, this is clearly adding something to the original title - maybe it's reasonable to allow that.
Why? They are getting the indexing right. What's wrong is generating a random number from 1 to 16 inclusive. They use RND(1) to generate a random float from 0 to 1, including 0, not including 1. They multiply by 15 (that's the mistake) to get a random float from 0 to 15, not including 15. They use INT to round down to get an INT from 0 to 14 inclusive, then add 1.
That gives them an INT from 1 to 15 (inclusive) to access the list of digits.
The mistake is they want an INT from 1 to 16, so they should have multiplied by 16.
Your link is to a page that talks about the difference between MID, which indexes from 1, and substring, which indexes from 0. Indexing from 1 is not the error, so I don't see why your link is relevant.
I think it might have to do with formatting the displayed output. There are nine columns in the display and the loop at line 45 puts nine values into L$. But why the GOSUB only occurs when I is 9 or 16 isn't clear.
Actually it is an old school delay loop -- it runs an empty loop from 1 to 200, which on the old computers would take some significant fraction of a second. This adds a slight delay after printing each line. Proper programming would call a sleep or usleep function, of course.
Oh, when I looked at this earlier, the second page of code wasn't there, so we had to guess what line 1000 looked like. I see the page has been updated (or my browser got its act together).
Right, the reason it won't ever emit F is because RND(1) will never return 1, it's implementation will return 0<=X<1, and INT() is a truncation, so INT(RND(1) + 15) will return an integer between 0 and 14. Adding one gives 1 to 15, and since F is in the 16th position of the string (Apple BASIC indexed from 1, not 0) it will never get selected.
INT(RND(1)+15) will always return 15 and nothing else, since the expected output would be a rounded-down integer value of (a random number between 0 and 0.99999999etc999, plus 15).
INT(RND(1) * 15), in contrast will produce a random whole number from 0 to 14. Hence the popular use of, for example, INT(RND(1) * 6)+1 in any given situation where a random number between 1 and 6 is required.
But they're using MID to extract a character from the string. Seems to me that string indexes are 1-based in Apple BASIC as evidenced by the " ... + 1" and the fact that there are 0's on the page. So you select from characters 1 to 16 in the string.
Edit: seems I was slower than all the other replies...