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 - david_uwi

Pages: [1] 2 3 ... 5
1
QB64 Discussion / Re: Time to bring in at least 150K new users to QB64
« on: April 04, 2022, 11:49:04 am »
That was a good point about anti-virus. Every time I install QB64 on a new machine I have to create exceptions in the antivirus software. Even executables I have made are flagged.
If any n00b downloads QB64 they are going to think it is malware and uninstall pretty quickly.
Is there anyway to address this as I'm sure it must deter many - if I download any program and the antivirus is activated I will immediately remove it.
I only know that QB64 is pukka as I have been using it for decades (and before that QB4.5 and GWBasic).

2
QB64 Discussion / Re: Question regarding interacting with Excel files
« on: April 02, 2022, 10:51:42 am »
Not sure about reading, but simple writing can be easy. My employer used* to insist on data being in excel files. So the easy way to do this is to get QB64 to open a text file and write the data separating them with a tab (chr$(9)) and LF, CR (CHR$(10)(13)) at the end of each line you can then paste it into an excel file.

*I am now happily retired

3
QB64 Discussion / Re: Time to bring in at least 150K new users to QB64
« on: March 28, 2022, 03:01:53 pm »
I have probably said this before (many times) very few younger people code. All the stuff they need has been written for them and they just download it (yes I'm looking at you Arduino and RPI). When I was a young lad many decades ago everybody who was studying science had a go at writing their own programs.
I saved a great amount of time in my work by writing dedicated programs particularly for data entry (with checking) - much easier and quicker than excel with *no mistakes*.




4
Programs / Re: Control digital, pwm and analog signals from QB64
« on: March 16, 2022, 02:49:38 pm »
I found that when reading into QB64 the baud rate in the open statement did not matter. I have not tried the other way as I don't have much data to transfer.
My transfer rate I feel is limited by how fast the other parts of the circuit can access the data. I was transferring weather data from a flash memory chip (part of a data-logger) to my PC. I've just looked up the memory chip FL132K and it seems to be obsolete (these thing happen quickly!) it holds 4 Mbytes may seem small, but even recording temperature and pressure reading every minute it can last a few years (the batteries run down first).

5
Programs / Re: Control digital, pwm and analog signals from QB64
« on: March 16, 2022, 11:10:23 am »
I use a FT201X connected to one of microchip's PIC chips (16F18326 usually) the chip has ADC and can read from other sensors using I2C and SPI.
The transfer rate I have observed seems to be governed by how fast the FT201X can access and transfer the data to the USB line.
In other words the baud rate you put in the OPEN COM line seems unimportant (it may well be for transfer the other way).
I get speeds of about 185 kbaud  (I can transfer 1 Mbyte in 45 secs) which is well over the supposed maximum of 115k.

6
Programs / Re: Language
« on: November 09, 2021, 07:35:54 am »
-2^-3^-4 evaluating left to right...
-2^-3=(1/-2)^3=-1/8
(-1/8)^-4=-8^4=4096

7
QB64 Discussion / Re: Possible error in INTEGER64 calculations
« on: September 29, 2021, 03:10:23 am »
It certainly could catch out the unaware.
That said it is integer arithmetic - both arguments 7 and 21 are integer so the answer is integer.
As long as there are no overflows it is reasonable to assume that the integer answer should be the correct answer, but it is not.

The compiler should not default to floats when doing integer calculations (but what do I know I've never tried to write a compiler so I have no clue as to the difficulties)

8
Probably these methods will not work anymore. Many years ago I needed to get short accurate delay. There were two ways to do this:
Read the "time stamp counter" - basically reading the CPU clock using ASM:RDTSC (HEX:0F31) as I was using a 160 MHz pentium the clock rate was 160 MHz.

The other way is to change the clock tick rate:
By setting &H40 and reading from &H46C and &H46D - probably only works with DOS :(

DEF SEG = 0
REM VALUES BELOW FOR CLOCK TICK RATE 10 ms and 1 ms
IH = 46: IL = 156 '10 ms
IH = 4: IL = 169 '1 ms
OUT &H43, &H34
OUT &H40, IL
OUT &H40, IH

WHILE PEEK(&H46C) < 40: WEND 'shortish delay
WHILE PEEK(&H46D) < 16: WEND 'longish delay

9
QB64 Discussion / Re: Possible error in INTEGER64 calculations
« on: September 25, 2021, 01:58:56 pm »
Interesting. I will bear that in mind when using ^.
I note that 7^21 is even further out
..284007 is correct putting in 7^21 the number ends in ends in ..284032 (25 too big).
"casting" (as I believe it is called) 7&&^21&& gives the same value as 7^21.

10
QB64 Discussion / Possible error in INTEGER64 calculations
« on: September 25, 2021, 04:19:42 am »
Sorry I've not got the latest version, so if this has been sorted you can delete this.

DIM z AS _INTEGER64
z = 7 ^ 19
PRINT z

The answer should end in ..373143, but the above gives ...373144


11
Programs / Re: Word ladder - Rosetta Code
« on: September 19, 2021, 02:30:55 am »
sse, gsa, btl - I would not count these as words (and there are many others which may be abbreviations or acronyns).
I think we need a better word list.

12
QB64 Discussion / Re: DATA statements, the QB64 IDE, and REM...
« on: September 17, 2021, 04:49:56 am »
I've been working with microprocessors in recent times and they generally have tables rather than DATA.
They seem to me to be much more useful. They work something like this:

for i=1 to n
READTABLE, mytable,i,mydata(i)
next i
.
.
Table mytable
100
200
300
.
.
end table
Would such a thing be useful if it were available in QB64?

I should note that for microprocessors RAM is often limited compared to program memory. (The table is stored in program memory)

13
Programs / Re: Word ladder - Rosetta Code
« on: September 15, 2021, 02:58:07 am »
I'm not sure that checking the last word for a path is a good idea. It works in this case, but I think that ADULT is something of an anomaly as there is no one letter substitution that will form a word - how often is that going to happen?

14
Programs / Re: Word ladder - Rosetta Code
« on: September 14, 2021, 02:25:42 pm »
More tweaking. This time a small change to the algorithm.
I realized that once you get to within one letter of q2$ (the goal word) it is essentially solved. No point in going through the word list one last time. So this new program aborts at this point 1-letter away from a solution.
It save a trivial amount of time 2.7 -->2.3 sec on my system.

I had no idea that ASC worked so much quicker than MID$ (who would have thought!)

Code: QB64: [Select]
  1. _TITLE "Word ladder v6 b+ mod david_uwi" '2021-09-10 david has already improved his first version!
  2. ' ref:  https://www.qb64.org/forum/index.php?topic=4157.msg135293#msg135293
  3. ' get original version above, I am modifying below to study
  4. ' 2021-09-11 in v3 b+ mod david_uwi I modify to compare whole set to my orignal whole set
  5. ' 2021-09-11 in v4 I think I can load the words faster
  6. ' 2021-09-12 in v5 lets just call the external file once, use david's idea instead of _continue,
  7. ' I think it looks cleaner without _continue which tool out skipping a For loop by a THEN (GOTO) line #.
  8. ' Ave of 5 runs before this (mod 4) was 11.27.. see if we improve still more, also DefLng A-Z  oh wow.
  9. ' Ave of 5 runs now 8.74 another 2.5 secs shaved off
  10. ' 2021-09-12 in v6 though using asc instead of mid$ might go faster.
  11. ' Ave of 5 runs now is 4.45 secs another 4.29 sec off!
  12.  
  13. ' 2021-09-13 v7 b+ mod david_uwi = v6 b+ mod but I will attempt to translate letter variables into
  14. ' more meaningful in attempts to understand what is being done in his code.
  15. ' Shaved significant time by making store$ (used to be q4) not fixed!
  16. ' Yes run a quick check that target word connects to something does save us so much time that
  17. ' we get a better overall time for the whole set even though we added a tiny bit of time to
  18. ' the ones that do connect.
  19. ' Ave of 5 runs is now 2.57 sec another 1.88 secs shaved off.
  20.  
  21. DEFLNG A-Z ' 2 secs off from old Single default!
  22. REDIM SHARED Fwords$(1 TO 1), UBF ' ubound of Fwords$
  23. start! = TIMER(.001)
  24.  
  25. ' do just once for all ladder calls
  26. OPEN "c:\cw1\unixdict.txt" FOR BINARY AS #1 ' take the file in a gulp
  27. buf$ = SPACE$(LOF(1))
  28. GET #1, , buf$
  29. Split buf$, CHR$(10), Fwords$()
  30. UBF = UBOUND(fwords$)
  31.  
  32. ' test set of ladder calls
  33. ladder "boy", "man" '     quick
  34. ladder "girl", "lady" '   this takes awhile
  35. ladder "john", "jane" '   quick enough
  36. ladder "alien", "drool" ' cool but takes a long long time!
  37. ladder "child", "adult" ' and this takes awhile
  38. ladder "play", "ball" '   goes quick
  39. ladder "fun", "job" '     ditto
  40. PRINT: PRINT "Total time including one disk file access:"; TIMER(.001) - start!
  41.  
  42. SUB ladder (q1$, q2$)
  43.     tt! = TIMER(.001) 'include time taken to load to RAM bplus mod to accuracy (.001)
  44.     DIM w(10000) AS STRING * 5 ' words from file not String * 5 'make sure we have enough storage!!
  45.     DIM store$(10000, 100) ' wow  went from fixed string! storing connect words  to not fixed string and shaved a sec off time!!!
  46.     DIM storeIndexs(100)
  47.     DIM z4(10000, 100) AS STRING
  48.     FI = 1
  49.     wordLength = LEN(q1$)
  50.     IF wordLength < 5 THEN q1$ = q1$ + SPACE$(5 - wordLength): q2$ = q2$ + SPACE$(5 - wordLength)
  51.     WHILE FI <= UBF
  52.         IF LEN(Fwords$(FI)) = wordLength THEN
  53.             maxWordIndex = maxWordIndex + 1
  54.             IF Fwords$(FI) = q1$ THEN w(maxWordIndex) = "*****" ELSE w(maxWordIndex) = Fwords$(FI)
  55.         END IF
  56.         FI = FI + 1
  57.     WEND
  58.  
  59.     'q2$ needs to have at least one connect or skip to end
  60.     '(this block will add a little more time to each ladder but save over a sec on adult or any target word with no connects)
  61.     FOR i = 1 TO maxWordIndex
  62.         IF w(i) <> q2$ THEN ' just check before entering loop
  63.             cnt = 0
  64.             FOR j = 1 TO wordLength
  65.                 IF ASC(w(i), j) <> ASC(q2$, j) THEN cnt = cnt + 1
  66.             NEXT j
  67.             IF cnt = 1 THEN ' q2$ has a connect good to go
  68.                 targetOK = -1: EXIT FOR
  69.             END IF
  70.         END IF
  71.     NEXT i
  72.     IF targetOK = 0 THEN PRINT "No path found! from "; q1$; " to "; q2$;: GOTO skip
  73.  
  74.     ' carry on
  75.     jk = 1
  76.     storeIndexs(jk) = 1
  77.     store$(1, 1) = q1$
  78.     DO
  79.         FOR i = 1 TO maxWordIndex
  80.             IF w(i) <> "*****" THEN '_Continue '  500  just check before entering loop
  81.                 cnt = 0
  82.                 FOR kk = 1 TO storeIndexs(jk)
  83.                     cnt = 0
  84.                     FOR j = 1 TO wordLength
  85.                         IF ASC(w(i), j) = ASC(store$(kk, jk), j) THEN cnt = cnt + 1 ELSE zz = j
  86.                         'If Mid$(w(i), j, 1) = Mid$(store$(kk, jk), j, 1) Then cnt = cnt + 1 Else zz = j
  87.                     NEXT j
  88.                     IF cnt = wordLength - 1 THEN
  89.                         storeIndexs(jk + 1) = storeIndexs(jk + 1) + 1
  90.                         store$(storeIndexs(jk + 1), jk + 1) = w(i)
  91.                         z4(storeIndexs(jk + 1), jk + 1) = z4(kk, jk) + MID$(w(i), zz, 1) + CHR$(zz + 48) + " " 'stores a letter and change position
  92.                         w(i) = "*****"
  93.                     END IF
  94.                 NEXT kk
  95.             END IF
  96.         NEXT i
  97.         kflag = 0
  98.  
  99.         '*****new routine!!!
  100.         cnu = 0
  101.         FOR i = 1 TO storeIndexs(jk + 1)
  102.             cnu = 0
  103.             FOR iq = 1 TO wordLength
  104.                 IF ASC(store$(i, jk + 1), iq) = ASC(q2$, iq) THEN cnu = cnu + 1
  105.             NEXT iq
  106.             IF cnu = wordLength - 1 THEN kflag = 99: final$ = z4(i, jk + 1)
  107.         NEXT i
  108.         '*********
  109.  
  110.         IF storeIndexs(jk + 1) = 0 THEN kflag = 99
  111.         jk = jk + 1
  112.         IF kflag = 99 THEN EXIT DO
  113.     LOOP
  114.     IF storeIndexs(jk) = 0 THEN PRINT "No path found! from "; q1$; " to "; q2$; ' b+ removed a print blank line
  115.     IF storeIndexs(jk) > 0 THEN
  116.         xlen = LEN(final$)
  117.         'Print:
  118.         PRINT q1$; " ";
  119.         FOR i = 1 TO xlen STEP 3
  120.             c1$ = MID$(final$, i, 1)
  121.             c2$ = MID$(final$, i + 1, 1)
  122.             MID$(q1$, VAL(c2$), 1) = c1$
  123.             PRINT q1$; " ";
  124.         NEXT i
  125.         PRINT q2$;
  126.     END IF
  127.     skip:
  128.     PRINT: PRINT "time taken = "; TIMER(.001) - tt!; " seconds"
  129.  
  130. SUB Split (SplitMeString AS STRING, delim AS STRING, loadMeArray() AS STRING)
  131.     DIM curpos AS LONG, arrpos AS LONG, LD AS LONG, dpos AS LONG 'fix use the Lbound the array already has
  132.     curpos = 1: arrpos = LBOUND(loadMeArray): LD = LEN(delim)
  133.     dpos = INSTR(curpos, SplitMeString, delim)
  134.     DO UNTIL dpos = 0
  135.         loadMeArray(arrpos) = MID$(SplitMeString, curpos, dpos - curpos)
  136.         arrpos = arrpos + 1
  137.         IF arrpos > UBOUND(loadMeArray) THEN REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO UBOUND(loadMeArray) + 1000) AS STRING
  138.         curpos = dpos + LD
  139.         dpos = INSTR(curpos, SplitMeString, delim)
  140.     LOOP
  141.     loadMeArray(arrpos) = MID$(SplitMeString, curpos)
  142.     REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO arrpos) AS STRING 'get the ubound correct
  143.  
  144.  
  145.  

15
Programs / Re: Word ladder - Rosetta Code
« on: September 14, 2021, 10:29:01 am »
Ah! stupid mistake. The unixdict is finding 5 word chains from five to bags - the bigger wordlist is finding 4 word chains (because it has words ending in "s").

Pages: [1] 2 3 ... 5