Re: C64 BASIC question



In part of my program i need to randomize a list of numbers without
duplicates. The code examples below are how I did it. The reason they
are so obfuscated is because everything that can be tokenized is
tokenized and no spaces are in between most of the commands.
It appears exactly as it looks on the screen in my emulator (vice
1.16). Both examples should produce the same results. But only the
first does. The only difference is on line 110 in the first example
the next command is on the next line (111). Whereas in the second the
next is on the same line (110). Wouldn't this in theory produce the
same result?

No because if the IF is false, the rest of the LINE is skipped, not just the next
statement in a multi-statement line. It's for that reason that it's not advised to
put NEXT in the same line as an IF.

Here's some code that makes things a bit easier (you can compress it yourself):

DIM USED%(14)
FOR C=0 TO 14
USED%(C)=C+1
NEXT
FOR C=0 TO 14
TEMP%=USED%(C)
INDEX=INT(RND(TI) * 15)
USED%(C)=USED%(INDEX)
USED%(INDEX)=TEMP%
NEXT

This willl give a random order to the numbers 1 to 15 in the array USED% with no
duplicates.

Tom Lake


.



Relevant Pages

  • Re: Hours Worked
    ... are you using ClockNo and Reason as a composite primary ... The warning about duplicates suggests that you may have these two keys as a ... composite primary key, which means that, even though each can accept ...
    (microsoft.public.access.gettingstarted)
  • testing
    ... My apologies for posting as a new post but for some reason when I reply to ... so sorry if this duplicates along the way.. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Hello PPl, is there a way of locking a design (NGC) to a particular FPGA board?
    ... no reason to be scared of arguing with me. ... My experience with these 1 wire electronic serial numbers was with Dallas semiconductor parts almost 15 years ago. ... the company I was working for was able to get duplicates made by Dallas. ...
    (comp.arch.fpga)
  • Re: Hours Worked
    ... ClockNo & Reason are the only "Keys" in that table, ... >composite primary key, which means that, even though ... >duplicates, there cannot be two records where the values ...
    (microsoft.public.access.gettingstarted)
  • Re: MD/RAID time out writing superblock
    ... is an issue with SMART in general, smartd issues SMART commands (I don't ... blacklist wouldn't be too good and so on and there's very good reason ... APM adjustment commands whenever power related stuff changes. ... There are plenty drives and configurations like that and different ...
    (Linux-Kernel)