Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Bert22306

Pages: [1] 2 3 ... 14
1
QB64 Discussion / Re: Just a Code Sample: EXIT SUB
« on: February 13, 2022, 10:41:44 pm »
This is QB64 man! You don't have to Declare Sub nor "Call" Subs. :)

FWIW, while I agree that having to declare all subs at the top was a bloody nuisance, "Call subfoo" is, IMO, way more readable, than just naming the sub. Especially when others need to read and understand your code.

2
QB64 Discussion / Re: Forum outages
« on: December 12, 2021, 06:58:50 pm »
We had a table in our database that kept error logs and it was going way beyond our server limits. Wiping it clean (and fixing the cause of said error logs in the php code) fixed it.

I may be wrong, but if I remember correctly, this is exactly what caused the humongously long outages when Galleon was running the show. He'd get busy with his real work, forget to check the server, and the log would overflow with errors. In that case, it went on for weeks. To the point where I often wondered whether the project had reached end of life. Very disconcerting. At least here, the outages were always short. Thanks, Fellippe!!

3
Programs / Re: Text and numbers to Morse code, and back again
« on: December 09, 2021, 09:44:42 pm »
Yes, that's exactly what I wanted to do next, but first I need a mic. I'll look to see what Steve and Spriggsy concocted. And to work right, it would have to accommodate a certain amount of slop in length, spacing, and frequencies of the tone.

4
Programs / Text and numbers to Morse code, and back again
« on: December 08, 2021, 07:37:11 pm »
An ASCII string is split up into individual characters, including spaces, and converted to Morse code. Including audio.

One subroutine converts to Morse, and another one decodes the dots and dashes back to text and numerals.

(Oh shucks. The accented u is meant to be a dot, character 249, in the IBM extended character set. It's a dot at the same elevation as the - sign. I use character 249 as dit, and the - symbol as dah. It shows up fine in QB64.)

Code: QB64: [Select]
  1. Rem  Program converts text to Morse code, including sound, then decodes.
  2. Rem -------
  3. _Title "Morse code encoder/decoder"
  4. Rem Screen _NewImage(120, 43, 0)
  5. Rem Color 1, 7
  6. Dim Shared char(500), MorseChar$(500), Astring$, NumBytes
  7. 1 Input "Continue or exit (x exits) -> ", cont$
  8. If cont$ = "x" Then End
  9. Call InputCharacters
  10. Call MorseEncode
  11. Input "Press <enter> to decode -> ", cont$
  12. Call MorseDecode
  13.  
  14. Sub InputCharacters
  15.     Input "Enter string of letters and numbers to convert to Morse code -> ", Astring$
  16.     Print Astring$
  17.     NumBytes = Len(Astring$)
  18.     For i = 1 To NumBytes
  19.         char(i) = Asc(Astring$, i)
  20.     Next i
  21.     If NumBytes < 1 Then
  22.         Beep
  23.         Print
  24.         Color 4, 7
  25.         Print "There was no input data identified. At least one input byte required."
  26.         Color 1, 7
  27.         End
  28.     End If
  29.     Print "Number of bytes ="; NumBytes
  30.  
  31. Sub MorseEncode
  32.     Print
  33.     For i = 1 To NumBytes
  34.         Rem -------
  35.         Rem  control codes
  36.         Rem -------
  37.         If char(i) < 32 Then
  38.             MorseChar$(i) = "*"
  39.             Print MorseChar$(i), "No Morse equivalent"
  40.             Call NoCode
  41.         End If
  42.         Rem -------
  43.         Rem  parentheses, slash, + and - signs
  44.         Rem -------
  45.         If char(i) > 33 And char(i) < 48 Then
  46.             MorseChar$(i) = "*"
  47.             Print MorseChar$(i), "No Morse equivalent"
  48.             Call NoCode
  49.         End If
  50.         Rem -------
  51.         Rem  colon, semicolon, >, <, ?, etc.
  52.         Rem -------
  53.         If char(i) > 57 And char(i) < 65 Then
  54.             MorseChar$(i) = "*"
  55.             Print MorseChar$(i), "No Morse equivalent"
  56.             Call NoCode
  57.         End If
  58.         Rem -------
  59.         Rem  brackets, backslash, etc.
  60.         Rem -------
  61.         If char(i) > 90 And char(i) < 97 Then
  62.             MorseChar$(i) = "*"
  63.             Print MorseChar$(i), "No Morse equivalent"
  64.             Call NoCode
  65.         End If
  66.         Rem -------
  67.         Rem  more brackets, extended ASCII set
  68.         Rem -------
  69.         If char(i) > 122 Then
  70.             MorseChar$(i) = "*"
  71.             Print MorseChar$(i), "No Morse equivalent"
  72.             Call NoCode
  73.         End If
  74.         Rem -------
  75.         Rem  Space between words
  76.         Rem -------
  77.         If char(i) = 32 Then
  78.             MorseChar$(i) = " "
  79.             Print MorseChar$(i)
  80.             _Delay .8
  81.         End If
  82.         Rem -------
  83.         Rem  Letter A
  84.         Rem -------
  85.         If char(i) = 97 Or char(i) = 65 Then
  86.             MorseChar$(i) = "ù-"
  87.             Print MorseChar$(i), Chr$(65)
  88.             Call dit: Call dah
  89.             _Delay .45
  90.         End If
  91.         Rem -------
  92.         Rem  Letter B
  93.         Rem -------
  94.         If char(i) = 98 Or char(i) = 66 Then
  95.             MorseChar$(i) = "-ùùù"
  96.             Print MorseChar$(i), Chr$(66)
  97.             Call dah: Call dit: Call dit: Call dit
  98.             _Delay .45
  99.         End If
  100.         Rem -------
  101.         Rem  Letter C
  102.         Rem -------
  103.         If char(i) = 99 Or char(i) = 67 Then
  104.             MorseChar$(i) = "-ù-ù"
  105.             Print MorseChar$(i), Chr$(67)
  106.             Call dah: Call dit: Call dah: Call dit
  107.             _Delay .45
  108.         End If
  109.         Rem -------
  110.         Rem  Letter D
  111.         Rem -------
  112.         If char(i) = 100 Or char(i) = 68 Then
  113.             MorseChar$(i) = "-ùù"
  114.             Print MorseChar$(i), Chr$(68)
  115.             Call dah: Call dit: Call dit
  116.             _Delay .45
  117.         End If
  118.         Rem -------
  119.         Rem  Letter E
  120.         Rem -------
  121.         If char(i) = 101 Or char(i) = 69 Then
  122.             MorseChar$(i) = "ù"
  123.             Print MorseChar$(i), Chr$(69)
  124.             Call dit
  125.             _Delay .45
  126.         End If
  127.         Rem -------
  128.         Rem  Letter F
  129.         Rem -------
  130.         If char(i) = 102 Or char(i) = 70 Then
  131.             MorseChar$(i) = "ùù-ù"
  132.             Print MorseChar$(i), Chr$(70)
  133.             Call dit: Call dit: Call dah: Call dit
  134.             _Delay .45
  135.         End If
  136.         Rem -------
  137.         Rem  Letter G
  138.         Rem -------
  139.         If char(i) = 103 Or char(i) = 71 Then
  140.             MorseChar$(i) = "--ù"
  141.             Print MorseChar$(i), Chr$(71)
  142.             Call dah: Call dah: Call dit
  143.             _Delay .45
  144.         End If
  145.         Rem -------
  146.         Rem  Letter H
  147.         Rem -------
  148.         If char(i) = 104 Or char(i) = 72 Then
  149.             MorseChar$(i) = "ùùùù"
  150.             Print MorseChar$(i), Chr$(72)
  151.             Call dit: Call dit: Call dit: Call dit
  152.             _Delay .45
  153.         End If
  154.         Rem -------
  155.         Rem  Letter I
  156.         Rem -------
  157.         If char(i) = 105 Or char(i) = 73 Then
  158.             MorseChar$(i) = "ùù"
  159.             Print MorseChar$(i), Chr$(73)
  160.             Call dit: Call dit
  161.             _Delay .45
  162.         End If
  163.         Rem -------
  164.         Rem  Letter J
  165.         Rem -------
  166.         If char(i) = 106 Or char(i) = 74 Then
  167.             MorseChar$(i) = "ù---"
  168.             Print MorseChar$(i), Chr$(74)
  169.             Call dit: Call dah: Call dah: Call dah
  170.             _Delay .45
  171.         End If
  172.         Rem -------
  173.         Rem  Letter K
  174.         Rem -------
  175.         If char(i) = 107 Or char(i) = 75 Then
  176.             MorseChar$(i) = "-ù-"
  177.             Print MorseChar$(i), Chr$(75)
  178.             Call dah: Call dit: Call dah
  179.             _Delay .45
  180.         End If
  181.         Rem -------
  182.         Rem  Letter L
  183.         Rem -------
  184.         If char(i) = 108 Or char(i) = 76 Then
  185.             MorseChar$(i) = "ù-ùù"
  186.             Print MorseChar$(i), Chr$(76)
  187.             Call dit: Call dah: Call dit: Call dit
  188.             _Delay .45
  189.         End If
  190.         Rem -------
  191.         Rem  Letter M
  192.         Rem -------
  193.         If char(i) = 109 Or char(i) = 77 Then
  194.             MorseChar$(i) = "--"
  195.             Print MorseChar$(i), Chr$(77)
  196.             Call dah: Call dah
  197.             _Delay .45
  198.         End If
  199.         Rem -------
  200.         Rem  Letter N
  201.         Rem -------
  202.         If char(i) = 110 Or char(i) = 78 Then
  203.             MorseChar$(i) = "-ù"
  204.             Print MorseChar$(i), Chr$(78)
  205.             Call dah: Call dit
  206.             _Delay .45
  207.         End If
  208.         Rem -------
  209.         Rem  Letter O
  210.         Rem -------
  211.         If char(i) = 111 Or char(i) = 79 Then
  212.             MorseChar$(i) = "---"
  213.             Print MorseChar$(i), Chr$(79)
  214.             Call dah: Call dah: Call dah
  215.             _Delay .45
  216.         End If
  217.         Rem -------
  218.         Rem  Letter P
  219.         Rem -------
  220.         If char(i) = 112 Or char(i) = 80 Then
  221.             MorseChar$(i) = "ù--ù"
  222.             Print MorseChar$(i), Chr$(80)
  223.             Call dit: Call dah: Call dah: Call dit
  224.             _Delay .45
  225.         End If
  226.         Rem -------
  227.         Rem  Letter Q
  228.         Rem -------
  229.         If char(i) = 113 Or char(i) = 81 Then
  230.             MorseChar$(i) = "--ù-"
  231.             Print MorseChar$(i), Chr$(81)
  232.             Call dah: Call dah: Call dit: Call dah
  233.             _Delay .45
  234.         End If
  235.         Rem -------
  236.         Rem  Letter R
  237.         Rem -------
  238.         If char(i) = 114 Or char(i) = 82 Then
  239.             MorseChar$(i) = "ù-ù"
  240.             Print MorseChar$(i), Chr$(82)
  241.             Call dit: Call dah: Call dit
  242.             _Delay .45
  243.         End If
  244.         Rem -------
  245.         Rem  Letter S
  246.         Rem -------
  247.         If char(i) = 115 Or char(i) = 83 Then
  248.             MorseChar$(i) = "ùùù"
  249.             Print MorseChar$(i), Chr$(83)
  250.             Call dit: Call dit: Call dit
  251.             _Delay .45
  252.         End If
  253.         Rem -------
  254.         Rem  Letter T
  255.         Rem -------
  256.         If char(i) = 116 Or char(i) = 84 Then
  257.             MorseChar$(i) = "-"
  258.             Print MorseChar$(i), Chr$(84)
  259.             Call dah
  260.             _Delay .45
  261.         End If
  262.         Rem -------
  263.         Rem  Letter U
  264.         Rem -------
  265.         If char(i) = 117 Or char(i) = 85 Then
  266.             MorseChar$(i) = "ùù-"
  267.             Print MorseChar$(i), Chr$(85)
  268.             Call dit: Call dit: Call dah
  269.             _Delay .45
  270.         End If
  271.         Rem -------
  272.         Rem  Letter V
  273.         Rem -------
  274.         If char(i) = 118 Or char(i) = 86 Then
  275.             MorseChar$(i) = "ùùù-"
  276.             Print MorseChar$(i), Chr$(86)
  277.             Call dit: Call dit: Call dit: Call dah
  278.             _Delay .45
  279.         End If
  280.         Rem -------
  281.         Rem  Letter W
  282.         Rem -------
  283.         If char(i) = 119 Or char(i) = 87 Then
  284.             MorseChar$(i) = "ù--"
  285.             Print MorseChar$(i), Chr$(87)
  286.             Call dit: Call dah: Call dah
  287.             _Delay .45
  288.         End If
  289.         Rem -------
  290.         Rem  Letter X
  291.         Rem -------
  292.         If char(i) = 120 Or char(i) = 88 Then
  293.             MorseChar$(i) = "-ùù-"
  294.             Print MorseChar$(i), Chr$(88)
  295.             Call dah: Call dit: Call dit: Call dah
  296.             _Delay .45
  297.         End If
  298.         Rem -------
  299.         Rem  Letter Y
  300.         Rem -------
  301.         If char(i) = 121 Or char(i) = 89 Then
  302.             MorseChar$(i) = "-ù--"
  303.             Print MorseChar$(i), Chr$(89)
  304.             Call dah: Call dit: Call dah: Call dah
  305.             _Delay .45
  306.         End If
  307.         Rem -------
  308.         Rem  Letter Z
  309.         Rem -------
  310.         If char(i) = 122 Or char(i) = 90 Then
  311.             MorseChar$(i) = "--ùù"
  312.             Print MorseChar$(i), Chr$(90)
  313.             Call dah: Call dah: Call dit: Call dit
  314.             _Delay .45
  315.         End If
  316.         Rem -------
  317.         Rem  Numeral 0
  318.         Rem -------
  319.         If char(i) = 48 Then
  320.             MorseChar$(i) = "-----"
  321.             Print MorseChar$(i), Chr$(48)
  322.             Call dah: Call dah: Call dah: Call dah: Call dah
  323.             _Delay .6
  324.         End If
  325.         Rem -------
  326.         Rem  Numeral 1
  327.         Rem -------
  328.         If char(i) = 49 Then
  329.             MorseChar$(i) = "ù----"
  330.             Print MorseChar$(i), Chr$(49)
  331.             Call dit: Call dah: Call dah: Call dah: Call dah
  332.             _Delay .6
  333.         End If
  334.         Rem -------
  335.         Rem  Numeral 2
  336.         Rem -------
  337.         If char(i) = 50 Then
  338.             MorseChar$(i) = "ùù---"
  339.             Print MorseChar$(i), Chr$(50)
  340.             Call dit: Call dit: Call dah: Call dah: Call dah
  341.             _Delay .6
  342.         End If
  343.         Rem -------
  344.         Rem  Numeral 3
  345.         Rem -------
  346.         If char(i) = 51 Then
  347.             MorseChar$(i) = "ùùù--"
  348.             Print MorseChar$(i), Chr$(51)
  349.             Call dit: Call dit: Call dit: Call dah: Call dah
  350.             _Delay .6
  351.         End If
  352.         Rem -------
  353.         Rem  Numeral 4
  354.         Rem -------
  355.         If char(i) = 52 Then
  356.             MorseChar$(i) = "ùùùù-"
  357.             Print MorseChar$(i), Chr$(52)
  358.             Call dit: Call dit: Call dit: Call dit: Call dah
  359.             _Delay .6
  360.         End If
  361.         Rem -------
  362.         Rem  Numeral 5
  363.         Rem -------
  364.         If char(i) = 53 Then
  365.             MorseChar$(i) = "ùùùùù"
  366.             Print MorseChar$(i), Chr$(53)
  367.             Call dit: Call dit: Call dit: Call dit: Call dit
  368.             _Delay .6
  369.         End If
  370.         Rem -------
  371.         Rem  Numeral 6
  372.         Rem -------
  373.         If char(i) = 54 Then
  374.             MorseChar$(i) = "-ùùùù"
  375.             Print MorseChar$(i), Chr$(54)
  376.             Call dah: Call dit: Call dit: Call dit: Call dit
  377.             _Delay .6
  378.         End If
  379.         Rem -------
  380.         Rem  Numeral 7
  381.         Rem -------
  382.         If char(i) = 55 Then
  383.             MorseChar$(i) = "--ùùù"
  384.             Print MorseChar$(i), Chr$(55)
  385.             Call dah: Call dah: Call dit: Call dit: Call dit
  386.             _Delay .6
  387.         End If
  388.         Rem -------
  389.         Rem  Numeral 8
  390.         Rem -------
  391.         If char(i) = 56 Then
  392.             MorseChar$(i) = "---ùù"
  393.             Print MorseChar$(i), Chr$(56)
  394.             Call dah: Call dah: Call dah: Call dit: Call dit
  395.             _Delay .6
  396.         End If
  397.         Rem -------
  398.         Rem  Numeral 9
  399.         Rem -------
  400.         If char(i) = 57 Then
  401.             MorseChar$(i) = "----ù"
  402.             Print MorseChar$(i), Chr$(57)
  403.             Call dah: Call dah: Call dah: Call dah: Call dit
  404.             _Delay .6
  405.         End If
  406.     Next i
  407.  
  408. Sub MorseDecode
  409.     Print
  410.     For i = 1 To NumBytes
  411.         Rem -------
  412.         Rem  control codes, punctuation, slashes, extended ASCII
  413.         Rem -------
  414.         If MorseChar$(i) = "*" Then Print MorseChar$(i); " decoded", "InvalidCode"
  415.         Rem -------
  416.         Rem  Space between words
  417.         Rem -------
  418.         If MorseChar$(i) = " " Then Print
  419.         Rem -------
  420.         Rem  Letter A
  421.         Rem -------
  422.         If MorseChar$(i) = "ù-" Then Print MorseChar$(i); " decoded", "A"
  423.         Rem -------
  424.         Rem  Letter B
  425.         Rem -------
  426.         If MorseChar$(i) = "-ùùù" Then Print MorseChar$(i); " decoded", "B"
  427.         Rem -------
  428.         Rem  Letter C
  429.         Rem -------
  430.         If MorseChar$(i) = "-ù-ù" Then Print MorseChar$(i); " decoded", "C"
  431.         Rem -------
  432.         Rem  Letter D
  433.         Rem -------
  434.         If MorseChar$(i) = "-ùù" Then Print MorseChar$(i); " decoded", "D"
  435.         Rem -------
  436.         Rem  Letter E
  437.         Rem -------
  438.         If MorseChar$(i) = "ù" Then Print MorseChar$(i); " decoded", "E"
  439.         Rem -------
  440.         Rem  Letter F
  441.         Rem -------
  442.         If MorseChar$(i) = "ùù-ù" Then Print MorseChar$(i); " decoded", "F"
  443.         Rem -------
  444.         Rem  Letter G
  445.         Rem -------
  446.         If MorseChar$(i) = "--ù" Then Print MorseChar$(i); " decoded", "G"
  447.         Rem -------
  448.         Rem  Letter H
  449.         Rem -------
  450.         If MorseChar$(i) = "ùùùù" Then Print MorseChar$(i); " decoded", "H"
  451.         Rem -------
  452.         Rem  Letter I
  453.         Rem -------
  454.         If MorseChar$(i) = "ùù" Then Print MorseChar$(i); " decoded", "I"
  455.         Rem -------
  456.         Rem  Letter J
  457.         Rem -------
  458.         If MorseChar$(i) = "ù---" Then Print MorseChar$(i); " decoded", "J"
  459.         Rem -------
  460.         Rem  Letter K
  461.         Rem -------
  462.         If MorseChar$(i) = "-ù-" Then Print MorseChar$(i); " decoded", "K"
  463.         Rem -------
  464.         Rem  Letter L
  465.         Rem -------
  466.         If MorseChar$(i) = "ù-ùù" Then Print MorseChar$(i); " decoded", "L"
  467.         Rem -------
  468.         Rem  Letter M
  469.         Rem -------
  470.         If MorseChar$(i) = "--" Then Print MorseChar$(i); " decoded", "M"
  471.         Rem -------
  472.         Rem  Letter N
  473.         Rem -------
  474.         If MorseChar$(i) = "-ù" Then Print MorseChar$(i); " decoded", "N"
  475.         Rem -------
  476.         Rem  Letter O
  477.         Rem -------
  478.         If MorseChar$(i) = "---" Then Print MorseChar$(i); " decoded", "O"
  479.         Rem -------
  480.         Rem  Letter P
  481.         Rem -------
  482.         If MorseChar$(i) = "ù--ù" Then Print MorseChar$(i); " decoded", "P"
  483.         Rem -------
  484.         Rem  Letter Q
  485.         Rem -------
  486.         If MorseChar$(i) = "--ù-" Then Print MorseChar$(i); " decoded", "Q"
  487.         Rem -------
  488.         Rem  Letter R
  489.         Rem -------
  490.         If MorseChar$(i) = "ù-ù" Then Print MorseChar$(i); " decoded", "R"
  491.         Rem -------
  492.         Rem  Letter S
  493.         Rem -------
  494.         If MorseChar$(i) = "ùùù" Then Print MorseChar$(i); " decoded", "S"
  495.         Rem -------
  496.         Rem  Letter T
  497.         Rem -------
  498.         If MorseChar$(i) = "-" Then Print MorseChar$(i); " decoded", "T"
  499.         Rem -------
  500.         Rem  Letter U
  501.         Rem -------
  502.         If MorseChar$(i) = "ùù-" Then Print MorseChar$(i); " decoded", "U"
  503.         Rem -------
  504.         Rem  Letter V
  505.         Rem -------
  506.         If MorseChar$(i) = "ùùù-" Then Print MorseChar$(i); " decoded", "V"
  507.         Rem -------
  508.         Rem  Letter W
  509.         Rem -------
  510.         If MorseChar$(i) = "ù--" Then Print MorseChar$(i); " decoded", "W"
  511.         Rem -------
  512.         Rem  Letter X
  513.         Rem -------
  514.         If MorseChar$(i) = "-ùù-" Then Print MorseChar$(i); " decoded", "X"
  515.         Rem -------
  516.         Rem  Letter Y
  517.         Rem -------
  518.         If MorseChar$(i) = "-ù--" Then Print MorseChar$(i); " decoded", "Y"
  519.         Rem -------
  520.         Rem  Letter Z
  521.         Rem -------
  522.         If MorseChar$(i) = "--ùù" Then Print MorseChar$(i); " decoded", "Z"
  523.         Rem -------
  524.         Rem  Numeral 0
  525.         Rem -------
  526.         If MorseChar$(i) = "-----" Then Print MorseChar$(i); " decoded", "0"
  527.         Rem -------
  528.         Rem  Numeral 1
  529.         Rem -------
  530.         If MorseChar$(i) = "ù----" Then Print MorseChar$(i); " decoded", "1"
  531.         Rem -------
  532.         Rem  Numeral 2
  533.         Rem -------
  534.         If MorseChar$(i) = "ùù---" Then Print MorseChar$(i); " decoded", "2"
  535.         Rem -------
  536.         Rem  Numeral 3
  537.         Rem -------
  538.         If MorseChar$(i) = "ùùù--" Then Print MorseChar$(i); " decoded", "3"
  539.         Rem -------
  540.         Rem  Numeral 4
  541.         Rem -------
  542.         If MorseChar$(i) = "ùùùù-" Then Print MorseChar$(i); " decoded", "4"
  543.         Rem -------
  544.         Rem  Numeral 5
  545.         Rem -------
  546.         If MorseChar$(i) = "ùùùùù" Then Print MorseChar$(i); " decoded", "5"
  547.         Rem -------
  548.         Rem  Numeral 6
  549.         Rem -------
  550.         If MorseChar$(i) = "-ùùùù" Then Print MorseChar$(i); " decoded", "6"
  551.         Rem -------
  552.         Rem  Numeral 7
  553.         Rem -------
  554.         If MorseChar$(i) = "--ùùù" Then Print MorseChar$(i); " decoded", "7"
  555.         Rem -------
  556.         Rem  Numeral 8
  557.         Rem -------
  558.         If MorseChar$(i) = "---ùù" Then Print MorseChar$(i); " decoded", "8"
  559.         Rem -------
  560.         Rem  Numeral 9
  561.         Rem -------
  562.         If MorseChar$(i) = "----ù" Then Print MorseChar$(i); " decoded", "9"
  563.     Next i
  564.  
  565. Sub NoCode
  566.     Sound 400, 2
  567.     _Delay .5
  568.  
  569. Sub dit
  570.     Sound 650, 2
  571.     _Delay .2
  572.  
  573. Sub dah
  574.     Sound 650, 6
  575.     _Delay .2
  576.  

5
QB64 Discussion / Re: Bad random numbers, or TIMER limitation...?
« on: October 26, 2021, 04:36:42 pm »
Could this also be related to the problem with the QB64 PRNG, when you cycle through a set of RND that is a power of 2? I'd say, to be on the safer side, always go through an odd number of RND in the loop?

See this, and how it creates a nice colorful pattern, over time.

Code: [Select]
Rem  Program creates dots using random x and y coordinates
Rem
Rem  To eliminate pattern, make sure the number of Rnd variables in
Rem  the loop are not a power of 2.
Rem -------
Do
    Call Initialize
    Call DrawDots
Loop
End

Sub Initialize
    _Title "Random Number Distribution"
    Screen _NewImage(840, 480, 12)
    Cls
End Sub

Sub DrawDots
    Randomize Timer
    Color 9
    Print "First random number this cycle"; Rnd
    Do
        x = Rnd * 840
        y = Rnd * 480
        c = 1 + Int(Rnd * 15)
        a4 = Rnd
        a5 = Rnd
        a6 = Rnd
        a7 = Rnd
        a8 = Rnd
        a9 = Rnd
        a10 = Rnd
        a11 = Rnd
        a12 = Rnd
        a13 = Rnd
        a14 = Rnd
        a15 = Rnd
        a16 = Rnd
        PSet (x, y), c
        _Delay .005
        If InKey$ = Chr$(27) Then Exit Do
    Loop
    Cls
    Locate 15, 35
    Input "Start with new seed (y/n)"; cont$
    If cont$ = "n" Then End
End Sub

6
QB64 Discussion / Re: QB64 download stats, from v1.3 to 2.0.1 (today)
« on: October 17, 2021, 05:10:51 pm »
It's unclear to me whether development build downloads are included in the totals. That's all I ever download.

Interesting stats, though. Would be nice to start seeing numbers in the millions. I think that would be achievable, for example, as Steve suggests, to include QB64 in the Microsoft Store.

7
Jeez, guys, aren't we exaggerating a bit? I think the moral of the story is same as it always is: don't go bleeding edge, if you want longer lifespan?

I had a 250 GB SSD in my previous work laptop, and it hung in there for more than 4 years (I kept blowing away the persistent requests to refresh, out of sheer laziness). Maybe that's the main thing. Don't go for multiple TB drives.

My new work PC's SSD is also 250 GB.

People who are packrats also demand the largest disc drives. Just as, people who have messy physical desks also have messy PC desktops. Ever noticed?

8
QB64 Discussion / Re: QB64 v2.0 released! ⭐️⭐️⭐️⭐️⭐️
« on: October 11, 2021, 03:05:59 pm »
Wow, that was fast. Let me add my sincere thanks to this team of gurus. Astonishingly better than QuickBasic ever was. You guys rock!

9
QB64 Discussion / Re: Error occurs with previously working Function
« on: October 05, 2021, 03:45:37 pm »
Well, I'm going crazy. Several things caused me to write new lyrics to "Careless Whispers."

Last night I woke up after watching Rugby on YouTube and low and behold a video done by @FellippeHeitor about subs and functions was playing, and he created an endless loop by calling a function within function. Then I read the post below. I lost it ...

Maybe it was all part of the dream.

Like, just the other day, I thought I had awakened. I was going about my business, talking to my wife, even, and then I said wait! How is there this wall to wall carpeting in this corner of the room, when we changed the floor to hardwood?

Crazy stuff. It was recursive, but it didn't give me that error message. Probably it would have now, though, that I installed the new dev build.

10
QB64 Discussion / Re: Error occurs with previously working Function
« on: October 05, 2021, 03:39:35 pm »
the new official Bin$ is out now https://www.qb64.org/forum/index.php?topic=4261, I strongly recomment you to update, because when I look on your provided code samples, then I see you still use my very old Bin$.

RhoSigma

Ah, so it was you. Yes, thanks, I updated the function to your latest version, and all works like a charm. Many thanks again, RhoSigma.

11
QB64 Discussion / Re: Error occurs with previously working Function
« on: October 05, 2021, 05:31:54 am »
Hey, many thanks, guys!! Glad to have this working again. I've been using it quite a bit, and suddenly discovered several broken programs today. I didn't do it!

12
QB64 Discussion / Error occurs with previously working Function
« on: October 05, 2021, 12:52:21 am »
This Binary function used to work just fine, until the latest dev update I installed today.

Code: [Select]
_Title "Test of BIN$ function"
Screen _NewImage(120, 43, 0)
Color 1, 7
Cls
1 Input "Enter decimal (0 exits) -> ", dec
If dec = 0 Then End
binvalue$ = Bin$(dec)
recdec = Val("&b" + binvalue$)
hexvalue$ = Hex$(dec)
Print "Decimal"; dec; "  equals binary "; binvalue$; "  equals hex "; hexvalue$; "  reconstructs to decimal"; recdec
Print
GoTo 1
End

'---------------------------------------------------------------------
'Function:  Convert any given dec/hex/oct number into a binary string.
'           Can handle positive and negative values and works in that
'           similar to the QB64 built-in HEX$ and OCT$ functions.
'
'Synopsis:  binary$ = BIN$ (value&&)
'
'Result:    binary$ --> the binary representation string of the given
'                       number without leading zeros for positive values
'                       and either 8/16/32 or 64 chars for negatives,
'                       depending on the input size
'
'Inputs:    value&& --> the pos./neg. number to convert, may also be
'                       given as &H or &O prefixed value
'
'Notes:     You may also pass in floating point values, as long as its
'           represented value fits into the _INTEGER64 (&&) input, hence
'           approx. -9.223372036854776E+18 to 9.223372036854776E+18.
'           Different from HEX$ and OCT$, BIN$ won't throw an overflow
'           error, if this range is exceeded, but the result is probably
'           wrong in such a case.
'---------------------------------------------------------------------
Function Bin$ (value&&)
    '--- option _explicit requirements ---
    Dim temp~&&, charPos%, highPos%
    '--- init ---
    temp~&& = value&&
    Bin$ = String$(64, "0"): charPos% = 64: highPos% = 64
    '--- convert ---
    Do
        If (temp~&& And 1) Then Mid$(Bin$, charPos%, 1) = "1": highPos% = charPos%
        charPos% = charPos% - 1: temp~&& = temp~&& \ 2
    Loop Until temp~&& = 0
    '--- adjust negative size ---
    If value&& < 0 Then
        If -value&& < &HFFFFFFFF~& Then highPos% = 33
        If -value&& < &H0000FFFF~& Then highPos% = 49
        If -value&& < &H000000FF~& Then highPos% = 57
        If -value&& < &H00000000~& Then highPos% = 1
    End If
    '--- set result ---
    Bin$ = Mid$(Bin$, highPos%)
End Function

Who was the helpful soul who wrote this? Bplus? I don't remember, but it wasn't Steve. Now I get this blocking error message, which refers to this line highlighted in red:

       If (temp~&& And 1) Then Mid$(Bin$, charPos%, 1) = "1": highPos% = charPos%

"Incorrect number of arguments passed to function on line 45.
Caused by (or after) MID$ ( BIN$, CHARPOS% , 1) = "1",1 "

Sorry, I don't know what that means, nor why suddenly there should be this fatal error? (I'm sure it's obvious to most decent programmers.)

Thanks!

13
QB64 Discussion / Re: QB64 competitors... It is an hard life!
« on: September 29, 2021, 04:41:57 pm »
Don't know about what others do, but I've been using QuickBasic for real work, for years. No problem.

Started with Fortran in college, then had to switch to Basic, on a remote a time sharing system, in grad school. Used that same time sharing system at my first job. Then used the HP Basic, at a remote work site, on an HP 9830. And then, when we got our first IBM PS/2s at work, just for the hell of it, I typed "basic" at the DOS c:\ prompt. Surprise! There was my Advanced Basic IDE, right in front of me.

Then QBasic appeared, with the better IDE. I always used those at work. Who could possibly complain? The company didn't have to shell out any more money, and just about anyone can understand Basic code.

Then, in spite of its "invisibility," when I got a 64-bit PC with a 64-bit Windows, I had to find a better way to keep using Basic. Hey, I just used a search engine, and found this "invisible" QB64, no problem. And not just that, but unlike the previous transitions, all my programs worked. A couple had minor bugs, but this was as pain-free a transition as ever.

I've never had anyone complain about using Basic. One C programmer only said it makes his head hurt. Other than that, as far as work goes, I'm not sure who can possibly complain, or on what grounds.

14
QB64 Discussion / Re: QB64 works fine on Windows 11!
« on: September 14, 2021, 05:55:42 pm »
Just ran into my first real gripe with Win 11 — the right click context menu has changed.  It was a simple right click, then select copy, or paste, or extract archive…

Now it’s right click, click “more options”, select from old menu as before.  There’s an extra, stupid, select/click involved in there now, which I personally find a very annoying move.

I have precisely the same gripe. How dumb is it, to hide an option as commonly used as "copy," behind a "more options" category? I don't really understand what could lead someone to make such a decision.

Other than niggling issues like that, I honestly don't see the point of all the fuss. We should be excited because now the task bar icons are centered? In reading some of the articles about Win11, turns out that this new taskbar required all new code. Whoopie doo, right? There might be changes that are making some people excited, but nothing obvious to me, the way I use the OS.

Oh, and no live tiles? I'm not heartbroken over that, but is this an improvement?

Anyway, the essential point is that the IDE works perfectly well, as do the .exe files generated by QB64.

15
QB64 Discussion / Re: QB64 works fine on Windows 11!
« on: September 08, 2021, 04:08:35 pm »
Ye, the QB64 performance seems mostly unchanged, perhaps a hair slower than it was with Win10. I'm not positive about that yet.

I use Steve's graphics speed test, and my own number crunching speed test program. Both give more or less the same results as before. In my test, which creates three groups of five results, I get one or two slightly higher numbers in each group, than previously. But, still beta testing days for Win11, and that sort of stuff gets improved over time.

So, good deal there. In Steve's graphics test, the high number was increased when I enabled virtualization based security (VBS). Even using Windows 10. The low number was unchanged by VBS. And my number crunching performance numbers also unchanged, by VBS.

Pages: [1] 2 3 ... 14