QB64.org Forum

Active Forums => Programs => Topic started by: carloscordeiro on September 06, 2020, 09:27:47 pm

Title: Sequence
Post by: carloscordeiro on September 06, 2020, 09:27:47 pm
Good evening everyone
Come again on this forum, ask for help on this program to show sequence starting with 3 until 09 dozens.
I spent two nights trying to get him to show and count how many times a sequence of 03 dozens or more came out. I did it shows, but I'm having a hard time getting him to count the strings.
Follow code for anyone who can help me.
Sequencia_11 is exactly what I want, but I'm having trouble making him count each sequence.
Sequencia_01 counts the sequences, but does not show all sequences on the screen.
Thank you very much, for all the attention I've had at other times.

Carlos,
Title: Re: Sequence
Post by: bplus on September 06, 2020, 10:45:57 pm
Hi @carloscordeiro

Are you just trying to add up the numbers in a record or data line in that txt file?
Title: Re: Sequence
Post by: carloscordeiro on September 07, 2020, 12:48:06 am
Thank you Bplus for responding.

I'm not just trying to add up the numbers of a record or data line in that txt file. I am trying to know in each line or record, how many 3 tens sequences there are in each line or record
Example: line "01 04 06 07 08 09 10 11 12 14 16 17 22 23 24" in this line there is a sequence of 07 tens and another of 3 tens or more. I want to do this for all lines in the.txt file.

I managed to do it with prime numbers using the same file.txt. Unfortunately I am having difficulty with the same sequence of numbers.
I'll send the prime number for you to get an idea.
Title: Re: Sequence
Post by: bplus on September 07, 2020, 01:11:18 am
Yes, I figured out that you were looking for runs:

Here is the best one:
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Dang you want all of the runs > 2 from each line, I just counted the best in each line.
Back to drawing board :)
Title: Re: Sequence
Post by: carloscordeiro on September 07, 2020, 01:30:46 am
This, I want to show the sequences on the screen, regardless of the tens and together shows how many came out. As in prime numbers.
My difficulty is to show the sequence and count them at the same time
Title: Re: Sequence
Post by: bplus on September 07, 2020, 01:44:09 am
Hi @carloscordeiro

Do you have a method to your coloring madness? How about a color for each sequence length so it's color coded?
Title: Re: Sequence
Post by: bplus on September 07, 2020, 02:37:25 am
News flash the highest sequence is 14!
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Sequence
Post by: bplus on September 07, 2020, 04:18:57 am
OK here we go!

This is a two part program. The first has to be run only once to Analyze the Seque.txt data file. It writes a Seque Analysis.txt file that has all the data you need ready to display.

Code: QB64: [Select]
  1. OPEN "Seque.txt" FOR INPUT AS #1
  2. OPEN "seque analysis.txt" FOR OUTPUT AS #2 'counts seq and start position
  3. DIM sq(1 TO 15) AS INTEGER
  4.     seq = 1: starts = 1: saveseq = 0: lineNum = lineNum + 1: lc$ = SPACE$(15)
  5.     LINE INPUT #1, fl$
  6.     FOR i = 1 TO 15
  7.         n = VAL(MID$(fl$, i * 3 - 2, 3))
  8.         PRINT n;
  9.         IF i > 1 THEN
  10.             IF n = lastn + 1 THEN 'start ofr cont seq
  11.                 seq = seq + 1
  12.             ELSE 'seq ended if it even started
  13.                 sq(seq) = sq(seq) + 1
  14.                 MID$(lc$, starts, seq) = STRING$(seq, HEX$(seq))
  15.                 seq = 1
  16.                 starts = i
  17.             END IF
  18.         END IF
  19.         lastn = n
  20.     NEXT
  21.     sq(seq) = sq(seq) + 1
  22.     MID$(lc$, starts, seq) = STRING$(seq, HEX$(seq))
  23.     PRINT lc$
  24.     b$ = ""
  25.     FOR i = 1 TO 15
  26.         b$ = b$ + STR$(sq(i))
  27.     NEXT
  28.     PRINT #2, fl$ + " " + lc$ + b$
  29.     'PRINT "asleep"
  30.     'SLEEP
  31. 'PRINT #2, "Highest sequence is " + _TRIM$(STR$(highseq)) + " on line #" + _TRIM$(STR$(saveLineNum))
  32. PRINT "File: seque analysis.txt is ready!"
  33.  
  34. 'hint
  35. 'FOR i = 0 TO 15
  36. '    PRINT HEX$(i), VAL("&H" + HEX$(i))
  37. 'NEXT
  38.  
  39.  

I count 35 lines :)



Now this next file is for the big Color Coded show, it has a color for ever sequence number for 1 to 15 just like screen 12! But we need more room to list the sequence count status every line makes to the cumulative total.

Anyway here is code for the Show:
Code: QB64: [Select]
  1. _TITLE "sequence show" ' b+ 2020=09-07
  2. DIM d(1 TO 2029) AS STRING
  3. SCREEN _NEWIMAGE(1200, 720, 12)
  4. _DELAY .25
  5. OPEN "seque analysis.txt" FOR INPUT AS #1
  6. FOR i = 1 TO 2029
  7.     LINE INPUT #1, d(i)
  8. 'PRINT d(2029)  ' good
  9. page = 0
  10. nextPage:
  11. FOR p = 1 TO 40
  12.     IF page + p < 2030 THEN
  13.         n$ = _TRIM$(STR$(page + p))
  14.         blank$ = SPACE$(6)
  15.         MID$(blank$, 2, LEN(n$)) = n$
  16.         COLOR 15
  17.         PRINT blank$;
  18.         fl$ = MID$(d(page + p), 1, 45)
  19.         cs$ = MID$(d(page + p), 46, 15)
  20.         sc$ = MID$(d(page + p), 62)
  21.         FOR i = 1 TO 15
  22.             COLOR VAL("&H" + MID$(cs$, i, 1))
  23.             PRINT MID$(fl$, i * 3 - 2, 3);
  24.         NEXT
  25.         REDIM dat$(0)
  26.         Split sc$, " ", dat$()
  27.         PRINT SPACE$(3);
  28.         FOR i = LBOUND(dat$) TO UBOUND(dat$)
  29.             COLOR i + 1
  30.             blank$ = SPACE$(6)
  31.             MID$(blank$, 1, LEN(dat$(i))) = dat$(i)
  32.             PRINT blank$;
  33.         NEXT
  34.         PRINT
  35.     ELSE
  36.         COLOR 15
  37.         PRINT SPACE$(64) + "*** End of Data ***"
  38.         EXIT FOR
  39.     END IF
  40. PRINT SPACE$(55) + "press u for page Up, d for page Down "
  41. getpage:
  42. pageDir$ = ""
  43. WHILE UCASE$(pageDir$) <> "U" AND UCASE$(pageDir$) <> "D"
  44.     pageDir$ = INKEY$
  45.     _LIMIT 60
  46. IF UCASE$(pageDir$) = "U" THEN
  47.     IF page - 40 >= 0 THEN page = page - 40 ELSE BEEP
  48. ELSEIF UCASE$(pageDir$) = "D" THEN
  49.     IF page + 40 <= 2040 THEN page = page + 40 ELSE BEEP
  50.     IF pageDir$ <> "" THEN BEEP
  51.     GOTO getpage
  52. GOTO nextPage
  53.  
  54. SUB Split (SplitMeString AS STRING, delim AS STRING, loadMeArray() AS STRING)
  55.     DIM curpos AS LONG, arrpos AS LONG, LD AS LONG, dpos AS LONG 'fix use the Lbound the array already has
  56.     curpos = 1: arrpos = LBOUND(loadMeArray): LD = LEN(delim)
  57.     dpos = INSTR(curpos, SplitMeString, delim)
  58.     DO UNTIL dpos = 0
  59.         loadMeArray(arrpos) = MID$(SplitMeString, curpos, dpos - curpos)
  60.         arrpos = arrpos + 1
  61.         IF arrpos > UBOUND(loadMeArray) THEN REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO UBOUND(loadMeArray) + 1000) AS STRING
  62.         curpos = dpos + LD
  63.         dpos = INSTR(curpos, SplitMeString, delim)
  64.     LOOP
  65.     loadMeArray(arrpos) = MID$(SplitMeString, curpos)
  66.     REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO arrpos) AS STRING 'get the ubound correct
  67.  
  68. 'hint
  69. 'FOR i = 0 TO 15
  70. '    PRINT HEX$(i), VAL("&H" + HEX$(i))
  71. 'NEXT
  72.  
  73.  
That program ran a little longer as I had to bring in the big gun, Split SUB ;-))

And here is what the final page on the Big Screen looks like:
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Sequence
Post by: carloscordeiro on September 07, 2020, 04:54:58 pm
Hi Bplus
You understood what I want, it was perfect.  Now I wanted to change the appearance of the screen a little
As it is an advanced schedule, I am not familiar. I can only create simple programs.
I want to change the list of times a sequence goes out to an accountant.
Leave only the file numbers with the colors running on the screen.

(((((((Hello @carloscordeiro.

Do you have a method for your crazy coloring? How about a color for each string length so that it is color-coded?)))))))


I hadn't thought about this hypothesis, I was putting the colors at random.

I really liked the size of the screen, it got a lot of space, but a learning experience.

I'll try to draw the screen here and send it to you if there is a possibility to put a counter.
Title: Re: Sequence
Post by: bplus on September 07, 2020, 05:04:24 pm
Hi Bplus
You understood what I want, it was perfect.  Now I wanted to change the appearance of the screen a little
As it is an advanced schedule, I am not familiar. I can only create simple programs.
I want to change the list of times a sequence goes out to an accountant.
Leave only the file numbers with the colors running on the screen.

(((((((Hello @carloscordeiro.

Do you have a method for your crazy coloring? How about a color for each string length so that it is color-coded?)))))))


I hadn't thought about this hypothesis, I was putting the colors at random.

I really liked the size of the screen, it got a lot of space, but a learning experience.

I'll try to draw the screen here and send it to you if there is a possibility to put a counter.

Hey @carloscordeiro

Have you figured out what the numbers on the right side are. They are cumulative totals of ALL sequence lengths including 1, 2, 3, .... all color coded to the QB color = length.

We could also do totals for each line. Then maybe do a cumulative total by a page number at the bottom of page?
Title: Re: Sequence
Post by: carloscordeiro on September 07, 2020, 06:53:28 pm
It would be like the attached image that I want to show.
I only drew 3 lines, but it would be for all lines
Title: Re: Sequence
Post by: carloscordeiro on September 07, 2020, 06:55:28 pm
I also wanted a standard color for the numbers that are not in the sequence, I mean, outside the sequences.
Title: Re: Sequence
Post by: carloscordeiro on September 07, 2020, 07:01:47 pm
Image counter correction
Title: Re: Sequence
Post by: bplus on September 07, 2020, 07:43:07 pm
Looks like you have it your way!

Here is what I did:
Code: QB64: [Select]
  1. _TITLE "sequence show mod #2" ' b+ 2020=09-07
  2. DIM d(1 TO 2029) AS STRING
  3. SCREEN _NEWIMAGE(700, 740, 12)
  4. _DELAY .25
  5. OPEN "seque analysis.txt" FOR INPUT AS #1
  6. FOR i = 1 TO 2029
  7.     LINE INPUT #1, d(i)
  8. 'PRINT d(2029)  ' good
  9. page = 0
  10. nextPage:
  11. FOR p = 1 TO 40
  12.     IF page + p < 2030 THEN
  13.         n$ = _TRIM$(STR$(page + p))
  14.         blank$ = SPACE$(6)
  15.         MID$(blank$, 2, LEN(n$)) = n$
  16.         COLOR 15
  17.         PRINT blank$;
  18.         fl$ = MID$(d(page + p), 1, 45)
  19.         cs$ = MID$(d(page + p), 46, 15)
  20.         sc$ = MID$(d(page + p), 62)
  21.         IF page = 0 AND p = 1 THEN
  22.             sc2$ = ""
  23.         ELSE
  24.             sc2$ = MID$(d(page + p - 1), 62)
  25.         END IF
  26.         FOR i = 1 TO 15
  27.             COLOR VAL("&H" + MID$(cs$, i, 1))
  28.             PRINT MID$(fl$, i * 3 - 2, 3);
  29.         NEXT
  30.         REDIM dat$(0), dat2$(0)
  31.         Split sc$, " ", dat$()
  32.         IF sc2$ <> "" THEN Split sc2$, " ", dat2$()
  33.         PRINT SPACE$(3);
  34.         FOR i = LBOUND(dat$) TO UBOUND(dat$)
  35.             COLOR i + 1
  36.             blank$ = SPACE$(2)
  37.             IF sc2$ <> "" THEN
  38.                 diff$ = _TRIM$(STR$(VAL(dat$(i)) - VAL(dat2$(i))))
  39.                 MID$(blank$, 1, LEN(diff$)) = diff$
  40.             ELSE
  41.                 MID$(blank$, 1, LEN(dat$(i))) = dat$(i)
  42.             END IF
  43.             PRINT blank$;
  44.         NEXT
  45.         PRINT
  46.     ELSE
  47.         COLOR 15
  48.         PRINT SPACE$(34) + "*** End of Data ***"
  49.         EXIT FOR
  50.     END IF
  51. FOR i = 1 TO 15
  52.     COLOR i
  53.     blank$ = SPACE$(10)
  54.     s$ = "seq of " + _TRIM$(STR$(i))
  55.     MID$(blank$, 2, LEN(s$)) = s$
  56.     PRINT blank$;
  57.     IF i = 8 THEN PRINT
  58. PRINT SPACE$(25) + "press u for page Up, d for page Down ";
  59. getpage:
  60. pageDir$ = ""
  61. WHILE UCASE$(pageDir$) <> "U" AND UCASE$(pageDir$) <> "D"
  62.     pageDir$ = INKEY$
  63.     _LIMIT 60
  64. IF UCASE$(pageDir$) = "U" THEN
  65.     IF page - 40 >= 0 THEN page = page - 40 ELSE BEEP
  66. ELSEIF UCASE$(pageDir$) = "D" THEN
  67.     IF page + 40 <= 2040 THEN page = page + 40 ELSE BEEP
  68.     IF pageDir$ <> "" THEN BEEP
  69.     GOTO getpage
  70. GOTO nextPage
  71.  
  72. SUB Split (SplitMeString AS STRING, delim AS STRING, loadMeArray() AS STRING)
  73.     DIM curpos AS LONG, arrpos AS LONG, LD AS LONG, dpos AS LONG 'fix use the Lbound the array already has
  74.     curpos = 1: arrpos = LBOUND(loadMeArray): LD = LEN(delim)
  75.     dpos = INSTR(curpos, SplitMeString, delim)
  76.     DO UNTIL dpos = 0
  77.         loadMeArray(arrpos) = MID$(SplitMeString, curpos, dpos - curpos)
  78.         arrpos = arrpos + 1
  79.         IF arrpos > UBOUND(loadMeArray) THEN REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO UBOUND(loadMeArray) + 1000) AS STRING
  80.         curpos = dpos + LD
  81.         dpos = INSTR(curpos, SplitMeString, delim)
  82.     LOOP
  83.     loadMeArray(arrpos) = MID$(SplitMeString, curpos)
  84.     REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO arrpos) AS STRING 'get the ubound correct
  85.  
  86. 'hint
  87. 'FOR i = 0 TO 15
  88. '    PRINT HEX$(i), VAL("&H" + HEX$(i))
  89. 'NEXT
  90.  
  91.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Sequence
Post by: carloscordeiro on September 07, 2020, 08:12:51 pm
I didn't do Bplus, this is just a drawing I did on the windows paintd

I just added the columns in to be displayed

Insert the counter to be able to draw, so you would have an idea of what I want
Title: Re: Sequence
Post by: bplus on September 08, 2020, 03:13:33 pm
I didn't do Bplus, this is just a drawing I did on the windows paintd

I just added the columns in to be displayed

Insert the counter to be able to draw, so you would have an idea of what I want

* Sequencia_20 Forum.bas (5.97 kB - downloaded 1 times.)

It must be an oversight, my _title on your code :(
Title: Re: Sequence
Post by: carloscordeiro on September 23, 2020, 06:47:13 pm
Hi Bplus
Good night, here in Brazil
Since September 8, 2020, your last post, I've been trying to modify your code for my sequence. But I couldn't, because your code is very advanced.
I decided to take a few lines of your code and try to make my sequence. Today I managed to show the sequences from 3 on the screen. However, my code was not perfect, it has an “X = X + 1” counter to identify the strings, but in some lines of the file, seque.txt adds an extra digit in the “X”, causing an inadequate count to occur.
To minimize the error, I made a patch that I don't like.
I spent nights trying to figure out why he counts too much and I couldn't find out.
I read several posts where you can modify a code for the better or fix it.

I come in the hope that you will analyze my code and find out where it does the wrong count.

See lines from the patch I made:
(((IF cor1 (x) = 0 OR VAL (n $) <> cor1 (x) THEN
         x = x - 1
     ELSE
         IF cor1 (x) = 0 OR VAL (n $) = cor1 (x) AND seq <= 2 THEN x = x - 1
     END IF)))

Thanks again, for answering all my posts

Carlos,
 
Title: Re: Sequence
Post by: bplus on September 23, 2020, 08:12:44 pm
Sorry @carloscordeiro

I can't make sense of what you are doing or are after. Your screen is too big for my laptop and Windows is complaining there is something malicious in the exe I made from your code and won't run anymore. (WTH? It did run at least once.)

One thing I would never do is start taking VAL of these digit strings, I recommend avoiding that. Compare strings of digits with strings of digits.

Make sure counters are reset to 0 at all possible places of restart.

Only advance a counter if the seq > 2 I think is what you want to do, because you don't want to track seq length of 1 or 2.

Title: Re: Sequence
Post by: carloscordeiro on September 23, 2020, 08:48:29 pm
I will decrease the screen size
Here is a picture of what I want, I mean, I did it, but it has bugs
Title: Re: Sequence
Post by: bplus on September 23, 2020, 08:53:48 pm
Ha ha! I confess I can't even make sense of my own code!

Are you trying to get a count of sequences of the whole page farthest to right?
Title: Re: Sequence
Post by: carloscordeiro on September 23, 2020, 08:59:05 pm
Bplus, I decrease the screen size.
I have already reviewed everything and did not find the fault, even so it continues on some lines if you delete this patch that I made. This patch does not happen bub
(((Patch: IF cor1 (x) = 0 OR VAL (n $) <> cor1 (x) THEN
         x = x - 1
     ELSE
         IF cor1 (x) = 0 OR VAL (n $) = cor1 (x) AND seq <= 2 THEN x = x - 1
     END IF)))
Title: Re: Sequence
Post by: carloscordeiro on September 23, 2020, 09:00:36 pm
Yes, exactly that
Title: Re: Sequence
Post by: bplus on September 23, 2020, 09:42:07 pm
Ohhhh  I ran a preliminary program to process the lines and made the file "seque analysis.txt" It had the counts of each line in a 15 character middle column and running totals for the current line through the whole file!

Code: QB64: [Select]
  1. OPEN "Seque.txt" FOR INPUT AS #1
  2. OPEN "seque analysis.txt" FOR OUTPUT AS #2 'counts seq and start position
  3. DIM sq(1 TO 15) AS INTEGER
  4.     seq = 1: starts = 1: saveseq = 0: lineNum = lineNum + 1: lc$ = SPACE$(15)
  5.     LINE INPUT #1, fl$
  6.     FOR i = 1 TO 15 'going through the 15 numbers in a line
  7.         n = VAL(MID$(fl$, i * 3 - 2, 3)) ' oh hell I did take val of string so I could compare current number with last
  8.         PRINT n;
  9.         IF i > 1 THEN 'if past the first number we can start comparing to last
  10.             IF n = lastn + 1 THEN 'start counting seq length
  11.                 seq = seq + 1
  12.             ELSE 'seq ended (if it even started)
  13.                 sq(seq) = sq(seq) + 1  'for seq of 1 to seq of 15
  14.                 MID$(lc$, starts, seq) = STRING$(seq, HEX$(seq))
  15.                 seq = 1
  16.                 starts = i
  17.             END IF
  18.         END IF
  19.         lastn = n
  20.     NEXT
  21.     sq(seq) = sq(seq) + 1
  22.     MID$(lc$, starts, seq) = STRING$(seq, HEX$(seq))
  23.     PRINT lc$
  24.     b$ = ""
  25.     FOR i = 1 TO 15
  26.         b$ = b$ + STR$(sq(i))
  27.     NEXT
  28.     PRINT #2, fl$ + " " + lc$ + b$
  29.     'PRINT "asleep"
  30.     'SLEEP
  31. 'PRINT #2, "Highest sequence is " + _TRIM$(STR$(highseq)) + " on line #" + _TRIM$(STR$(saveLineNum))
  32. PRINT "File: seque analysis.txt is ready!"
  33.  
  34. 'hint
  35. 'FOR i = 0 TO 15
  36. '    PRINT HEX$(i), VAL("&H" + HEX$(i))
  37. 'NEXT
  38.  
  39.  

Here is output while analysis is working:
 


The numbers on left are just copies of the data, the numbers on right in a string of 15 are the sequence lengths each of the 15 data numbers belong to, also used for QB4.5 color codes this makes display of color coded numbers easy as eating pie.

From analysis file written you can display the numbers anyway you please! :) problem solved again ;-))


Here is a snippet of the analysis txt file:
Quote
02 03 05 06 09 10 11 13 14 16 18 20 23 24 25 222233322111333 3 3 2 0 0 0 0 0 0 0 0 0 0 0 0
01 04 05 06 07 09 11 12 13 15 16 19 20 23 24 144441333222222 5 6 3 1 0 0 0 0 0 0 0 0 0 0 0
01 04 06 07 08 09 10 11 12 14 16 17 20 23 24 117777777122122 9 8 3 1 0 0 1 0 0 0 0 0 0 0 0
01 02 04 05 08 10 12 13 16 17 18 19 23 24 25 222211224444333 11 11 4 2 0 0 1 0 0 0 0 0 0 0 0
01 02 04 08 09 11 12 13 15 16 19 20 23 24 25 221223332222333 12 15 6 2 0 0 1 0 0 0 0 0 0 0 0
01 02 04 05 06 07 10 12 15 16 17 19 21 23 25 224444113331111 18 16 7 3 0 0 1 0 0 0 0 0 0 0 0
01 04 07 08 10 12 14 15 16 18 19 21 22 23 25 112211333223331 23 18 9 3 0 0 1 0 0 0 0 0 0 0 0
01 05 06 08 09 10 13 15 16 17 18 19 20 22 25 122333166666611 27 19 10 3 0 1 1 0 0 0 0 0 0 0 0
03 04 05 09 10 11 13 15 16 17 19 20 21 24 25 333333133333322 28 20 14 3 0 1 1 0 0 0 0 0 0 0 0
02 03 04 05 06 08 09 10 11 12 14 19 20 23 24 555555555512222 29 22 14 3 2 1 1 0 0 0 0 0 0 0 0
02 06 07 08 09 10 11 12 16 19 20 22 23 24 25 177777771224444 31 23 14 4 2 1 2 0 0 0 0 0 0 0 0
01 02 04 05 07 08 09 10 11 12 14 16 17 24 25 222266666612222 32 27 14 4 2 2 2 0 0 0 0 0 0 0 0
03 05 06 07 08 09 10 11 13 14 15 16 17 19 23 177777775555511 35 27 14 4 3 2 3 0 0 0 0 0 0 0 0
01 02 05 06 07 09 13 14 15 18 19 20 21 23 25 223331333444411 38 28 16 5 3 2 3 0 0 0 0 0 0 0 0
01 02 04 06 08 10 12 15 16 18 19 21 23 24 25 221111122221333 44 31 17 5 3 2 3 0 0 0 0 0 0 0 0
02 05 06 07 08 10 12 13 15 17 19 21 23 24 25 144441221111333 50 32 18 6 3 2 3 0 0 0 0 0 0 0 0
01 02 03 05 06 07 09 13 14 16 17 18 19 20 21 333333122666666 51 33 20 6 3 3 3 0 0 0 0 0 0 0 0
02 06 07 08 10 11 14 15 17 18 19 20 22 23 24 133322224444333 52 35 22 7 3 3 3 0 0 0 0 0 0 0 0
02 05 06 07 08 10 11 13 14 15 16 17 20 23 24 144442255555122 54 37 22 8 4 3 3 0 0 0 0 0 0 0 0
03 04 06 07 08 09 10 14 16 17 18 19 20 23 24 225555515555522 55 39 22 8 6 3 3 0 0 0 0 0 0 0 0
01 02 04 05 08 11 14 16 18 19 20 22 23 24 25 222211113334444 59 41 23 9 6 3 3 0 0 0 0 0 0 0 0
01 02 03 04 05 06 07 09 10 12 13 14 15 22 25 777777722444411 61 42 23 10 6 3 4 0 0 0 0 0 0 0 0
01 03 04 05 06 08 10 11 12 14 16 17 18 19 20 144441333155555 64 42 24 11 7 3 4 0 0 0 0 0 0 0 0
01 02 03 05 07 10 11 14 17 19 20 21 23 24 25 333112211333333 68 43 27 11 7 3 4 0 0 0 0 0 0 0 0
01 02 03 04 05 06 07 09 13 14 16 20 22 23 24 777777712211333 71 44 28 11 7 3 5 0 0 0 0 0 0 0 0
05 07 08 09 10 11 13 14 16 17 19 20 21 22 23 155555222255555 72 46 28 11 9 3 5 0 0 0 0 0 0 0 0
03 06 08 10 11 12 13 14 15 18 20 21 22 24 25 111666666133322 76 47 29 11 9 4 5 0 0 0 0 0 0 0 0
01 03 07 09 10 11 12 13 14 16 17 18 19 20 21 111666666666666 79 47 29 11 9 6 5 0 0 0 0 0 0 0 0

On the far right I was keeping a running total of all the sequence numbers so if you wanted to know about the current line sequence counts just take the current line total and subtract the last line's current total.

So to do your seq counts, do that, subtract current line running totals from previous line and ignore the sequences of 1 or 2 because you don't seem to care about those, and print seq 3 = 2 seq 5 = 1 or whatever...

And while doing that, add the sequence counts for the page of how many ever lines you are doing for the page for printing onto the screen your own show.

Yes so in summary, use the analysis code to get the numbers you need for showing your data, then write your own show of the data in whatever way you desire to see the data.
Title: Re: Sequence
Post by: carloscordeiro on September 23, 2020, 10:38:49 pm
Bplus, are you talking about these underlined numbers? I see it gets easier. My difficulty is to extract from your file that you created to insert in my show code.

You are very excited, so I always thank you for all your attention.
Could you in a few lines like I do to extract the ready-made sequence from the file you created?
Title: Re: Sequence
Post by: bplus on September 23, 2020, 11:32:18 pm
Carlos, I have written my Show Mod #2 with comments to make it easy to follow and I included comments to show how you might modify the code to show what you want to show:

Code: QB64: [Select]
  1. _TITLE "sequence show mod #2" ' b+ 2020=09-07
  2. DIM d(1 TO 2029) AS STRING
  3. SCREEN _NEWIMAGE(700, 740, 12)
  4. _DELAY .25
  5. OPEN "seque analysis.txt" FOR INPUT AS #1 '  <  load all the lines from analysis into d() string array
  6. FOR i = 1 TO 2029
  7.     LINE INPUT #1, d(i)
  8. 'PRINT d(2029)  ' good
  9. page = 0 ' <  I am showing pages of 40 lines at a time  starting at page 0
  10. nextPage:
  11.  
  12. ' !!! carlos redim seqPage(1 to 15)   'to save running total of seq length counts
  13.  
  14. FOR p = 1 TO 40 ' <<                      each line is p added to page (a multiple of 40)
  15.  
  16.     '!!! carlos redim seqLength( 1 to 15)
  17.  
  18.     IF page + p < 2030 THEN
  19.         n$ = _TRIM$(STR$(page + p)) ' this is the line number in the data file ready to display
  20.         blank$ = SPACE$(6)
  21.         MID$(blank$, 2, LEN(n$)) = n$ '<  i insert the line number into a blank of 6 spaces
  22.         COLOR 15
  23.         PRINT blank$; ' <  OK there is the line number on screen
  24.  
  25.         ' now the data line has 3 parts
  26.         fl$ = MID$(d(page + p), 1, 45) '   <<< this is the 15 2 digit numbers
  27.         cs$ = MID$(d(page + p), 46, 15) '  <<< this is the 15 color codes for those numbers
  28.         sc$ = MID$(d(page + p), 62) '      <<< this is the running total of each sequence lenth count
  29.  
  30.  
  31.         'get the previous running total of each sequence lenth count
  32.         IF page = 0 AND p = 1 THEN ' no previous line
  33.             sc2$ = ""
  34.         ELSE
  35.             sc2$ = MID$(d(page + p - 1), 62) ' this section of the previous line contains the running totals
  36.         END IF
  37.  
  38.         ' now we will show the 15 numbers color coded with QB4.5 numbers
  39.         FOR i = 1 TO 15
  40.             COLOR VAL("&H" + MID$(cs$, i, 1)) ' set the color
  41.             PRINT MID$(fl$, i * 3 - 2, 3); ' print the number
  42.         NEXT
  43.  
  44.  
  45.         'Now to figure the sequence length counts for the line.
  46.  
  47.         '                         We will be using Split a powerful parsing tool!
  48.  
  49.         REDIM dat$(0), dat2$(0) ' this sets up 2 dynamic arrays to contain numbers of running totals
  50.  
  51.         Split sc$, " ", dat$() ' this splits sc$ section into an array of numbers the current line running totals here
  52.  
  53.         IF sc2$ <> "" THEN Split sc2$, " ", dat2$() ' this splits the previous line running totals into an array of numbers
  54.  
  55.  
  56.         PRINT SPACE$(3); ' just separate the line with some space
  57.  
  58.  
  59.         FOR i = LBOUND(dat$) TO UBOUND(dat$) ' current line running totals
  60.             COLOR i + 1 ' set color code for sequence
  61.  
  62.  
  63.             '                             carlos you would want to skip this next block
  64.  
  65.             ' now subtract from current line running totals the previous line if there was one
  66.             blank$ = SPACE$(2) '  load our arithmatic into a 2 space blank
  67.             IF sc2$ <> "" THEN
  68.                 diff$ = _TRIM$(STR$(VAL(dat$(i)) - VAL(dat2$(i)))) ' do subraction and convert number to string
  69.                 MID$(blank$, 1, LEN(diff$)) = diff$ ' < the diffence of the running total for a given seq length
  70.             ELSE
  71.                 MID$(blank$, 1, LEN(dat$(i))) = dat$(i)
  72.             END IF
  73.             PRINT blank$; ' and here is goes onto our line
  74.  
  75.  
  76.             '                                  Carlos here is where you want to do something different
  77.             ' i = 1 and i = 2 you dont want
  78.             ' You need to setup:
  79.             'different diff calcs
  80.             ' if sc2$ <> "" then
  81.             'diff = VAL(dat$(i)) - VAL(dat2$(i))
  82.             'ELSE
  83.             ' diff =val( dat$(i))
  84.             'end if
  85.  
  86.             ' an array (cleared for each line) to hold the maybe:               seqLength(i) = seqLength(i) + diff
  87.             ' and array for the page to hold the running totals for the page:   seqPage(i) = seqPage(i) + diff
  88.  
  89.         NEXT
  90.  
  91.         ' !!! Carlos from seqLength build a line that list the seq length and counts for seqLength() array
  92.       [s] ' b$ = ""  ' start a build string[/s]
  93.         ' for i = 3 to 15
  94.             ' color i
  95.        '        if seqLength(i) then ? "seq Length"; str$(i); " amount = " ; str$(seqLength(i));
  96.         '  next
  97.         ' !!! and print it to finish your lines
  98.       [s]  ' print b$   'finish your data line [/s]
  99.  
  100.         PRINT ' line is finished finally !
  101.     ELSE
  102.         COLOR 15
  103.         PRINT SPACE$(34) + "*** End of Data ***"
  104.         EXIT FOR
  105.     END IF
  106.  
  107. ' !!!!!!!!!! Carlos locate and print the data from the seqPage() totals now
  108. '  remember the QB color is same as i
  109. 'FOR i = 3 TO 15
  110. '      color i
  111. '       if seqPage(i) then locate i, someX past already written stuff : print total i lengths this page = seqPage(i)
  112. 'next
  113.  
  114. FOR i = 1 TO 15 'this is color code legend I write at bottom of screen
  115.     COLOR i
  116.     blank$ = SPACE$(10)
  117.     s$ = "seq of " + _TRIM$(STR$(i))
  118.     MID$(blank$, 2, LEN(s$)) = s$
  119.     PRINT blank$;
  120.     IF i = 8 THEN PRINT
  121.  
  122. 'last bit of instruction for page
  123. PRINT SPACE$(25) + "press u for page Up, d for page Down ";
  124.  
  125.  
  126.  
  127. ' now wait for keypress to page up or page down   and handle it
  128. getpage:
  129. pageDir$ = ""
  130. WHILE UCASE$(pageDir$) <> "U" AND UCASE$(pageDir$) <> "D"
  131.     pageDir$ = INKEY$
  132.     _LIMIT 60
  133. IF UCASE$(pageDir$) = "U" THEN
  134.     IF page - 40 >= 0 THEN page = page - 40 ELSE BEEP
  135. ELSEIF UCASE$(pageDir$) = "D" THEN
  136.     IF page + 40 <= 2040 THEN page = page + 40 ELSE BEEP
  137.     IF pageDir$ <> "" THEN BEEP
  138.     GOTO getpage
  139. GOTO nextPage
  140.  
  141.  
  142.  
  143. '                a very powerful parsing tool!!!
  144.  
  145. SUB Split (SplitMeString AS STRING, delim AS STRING, loadMeArray() AS STRING)
  146.     DIM curpos AS LONG, arrpos AS LONG, LD AS LONG, dpos AS LONG 'fix use the Lbound the array already has
  147.     curpos = 1: arrpos = LBOUND(loadMeArray): LD = LEN(delim)
  148.     dpos = INSTR(curpos, SplitMeString, delim)
  149.     DO UNTIL dpos = 0
  150.         loadMeArray(arrpos) = MID$(SplitMeString, curpos, dpos - curpos)
  151.         arrpos = arrpos + 1
  152.         IF arrpos > UBOUND(loadMeArray) THEN REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO UBOUND(loadMeArray) + 1000) AS STRING
  153.         curpos = dpos + LD
  154.         dpos = INSTR(curpos, SplitMeString, delim)
  155.     LOOP
  156.     loadMeArray(arrpos) = MID$(SplitMeString, curpos)
  157.     REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO arrpos) AS STRING 'get the ubound correct
  158.  
  159.  
  160.  
  161. 'hint   to color code writing
  162. 'FOR i = 0 TO 15
  163. '    PRINT HEX$(i), VAL("&H" + HEX$(i))
  164. 'NEXT
  165.  
  166.  
Title: Re: Sequence
Post by: bplus on September 24, 2020, 12:40:27 am
I am testing my ideas and found something important to change:
Code: QB64: [Select]
  1. REDIM dat$(0), dat2$(0)
  2.  

to
 
Code: QB64: [Select]
  1. REDIM dat$(1 to 1), dat2$(1 to 1)  'make lower bound of dat$ 1 not 0 for ease of code changes further on.
  2.  
Title: Re: Sequence
Post by: bplus on September 24, 2020, 12:51:08 am
Yep other than REDIM Dat$(1 to 1) arrays, it ran with few corrections:
Code: QB64: [Select]
  1. _TITLE "sequence show mod #2" ' b+ 2020=09-07
  2. DIM d(1 TO 2029) AS STRING
  3. SCREEN _NEWIMAGE(1180, 740, 12)
  4. _DELAY .25
  5. OPEN "seque analysis.txt" FOR INPUT AS #1 '  <  load all the lines from analysis into d() string array
  6. FOR i = 1 TO 2029
  7.     LINE INPUT #1, d(i)
  8. 'PRINT d(2029)  ' good
  9. page = 0 ' <  I am showing pages of 40 lines at a time  starting at page 0
  10. nextPage:
  11.  
  12. ' !!! carlos redim seqPage(1 to 15)   'to save running total of seq length counts
  13. REDIM seqPage(1 TO 15)
  14. FOR p = 1 TO 40 ' <<                      each line is p added to page (a multiple of 40)
  15.  
  16.     '!!! carlos redim seqLength( 1 to 15)
  17.     REDIM seqLength(1 TO 15)
  18.  
  19.     IF page + p < 2030 THEN
  20.         n$ = _TRIM$(STR$(page + p)) ' this is the line number in the data file ready to display
  21.         blank$ = SPACE$(6)
  22.         MID$(blank$, 2, LEN(n$)) = n$ '<  i insert the line number into a blank of 6 spaces
  23.         COLOR 15
  24.         PRINT blank$; ' <  OK there is the line number on screen
  25.  
  26.         ' now the data line has 3 parts
  27.         fl$ = MID$(d(page + p), 1, 45) '   <<< this is the 15 2 digit numbers
  28.         cs$ = MID$(d(page + p), 46, 15) '  <<< this is the 15 color codes for those numbers
  29.         sc$ = MID$(d(page + p), 62) '      <<< this is the running total of each sequence lenth count
  30.  
  31.  
  32.         'get the previous running total of each sequence lenth count
  33.         IF page = 0 AND p = 1 THEN ' no previous line
  34.             sc2$ = ""
  35.         ELSE
  36.             sc2$ = MID$(d(page + p - 1), 62) ' this section of the previous line contains the running totals
  37.         END IF
  38.  
  39.         ' now we will show the 15 numbers color coded with QB4.5 numbers
  40.         FOR i = 1 TO 15
  41.             COLOR VAL("&H" + MID$(cs$, i, 1)) ' set the color
  42.             PRINT MID$(fl$, i * 3 - 2, 3); ' print the number
  43.         NEXT
  44.  
  45.  
  46.         'Now to figure the sequence length counts for the line.
  47.  
  48.         '                         We will be using Split a powerful parsing tool!
  49.  
  50.         REDIM dat$(1 TO 1), dat2$(1 TO 1) ' this sets up 2 dynamic arrays to contain numbers of running totals
  51.  
  52.         Split sc$, " ", dat$() ' this splits sc$ section into and array of numbers  the currnet line running totals here
  53.  
  54.         IF sc2$ <> "" THEN Split sc2$, " ", dat2$() ' this splits the previous line running totals into an array of numbers
  55.  
  56.  
  57.         PRINT SPACE$(3); ' just separate the line with some space
  58.  
  59.         'PRINT LBOUND(dat$), UBOUND(dat$)
  60.         'END
  61.  
  62.         FOR i = LBOUND(dat$) TO UBOUND(dat$) ' current line running totals
  63.  
  64.             COLOR i ' set color code for sequence
  65.  
  66.             ' now subtract from current line running totals the previous line if there was one
  67.             'blank$ = SPACE$(2) '  load our arithmatic into a 2 space blank
  68.             'IF sc2$ <> "" THEN
  69.             '    diff$ = _TRIM$(STR$(VAL(dat$(i)) - VAL(dat2$(i)))) ' do subraction and convert number to string
  70.             '    MID$(blank$, 1, LEN(diff$)) = diff$ ' < the diffence of the running total for a given seq length
  71.             'ELSE
  72.             '    MID$(blank$, 1, LEN(dat$(i))) = dat$(i)
  73.             'END IF
  74.             'PRINT blank$; ' and here is goes onto our line
  75.  
  76.  
  77.             'Carlos here is where you want to do something different
  78.             ' i = 1 and i = 2 you dont want
  79.             ' You need to setup:
  80.             'different diff calcs
  81.             IF sc2$ <> "" THEN
  82.                 diff = VAL(dat$(i)) - VAL(dat2$(i))
  83.             ELSE
  84.                 diff = VAL(dat$(i))
  85.             END IF
  86.  
  87.             ' an array (cleared for each line) to hold the maybe:               seqLength(i) = seqLength(i) + diff
  88.             ' and array for the page to hold the running totals for the page:   seqPage(i) = seqPage(i) + diff
  89.             seqLength(i) = seqLength(i) + diff
  90.             seqPage(i) = seqPage(i) + diff
  91.         NEXT
  92.  
  93.         ' !!! Carlos from seqLength build a line that list the seq length and counts for seqLength() array
  94.         ' !!! and print it to finish your lines
  95.         FOR i = 3 TO 15
  96.             COLOR i
  97.             IF seqLength(i) THEN PRINT "  seq"; i; "="; seqLength(i);
  98.         NEXT
  99.         '!!! and print it to finish your lines
  100.  
  101.  
  102.         PRINT ' my line is finished finally !
  103.     ELSE
  104.         COLOR 15
  105.         PRINT SPACE$(34) + "*** End of Data ***"
  106.         EXIT FOR
  107.     END IF
  108.  
  109. ' !!!!!!!!!! Carlos locate and print the data from the seqPage() totals now
  110. '  remember the QB color is same as i
  111. FOR i = 3 TO 15
  112.     COLOR i
  113.     IF seqPage(i) THEN LOCATE i, 100: PRINT "Total"; i; "lengths this page ="; seqPage(i)
  114.  
  115. LOCATE 42, 1
  116. FOR i = 1 TO 15 'this is color code legend I write at bottom of screen
  117.     COLOR i
  118.     blank$ = SPACE$(10)
  119.     s$ = "seq of " + _TRIM$(STR$(i))
  120.     MID$(blank$, 2, LEN(s$)) = s$
  121.     PRINT blank$;
  122.     IF i = 8 THEN PRINT
  123.  
  124. 'ast bit of instruction for page
  125. PRINT SPACE$(25) + "press u for page Up, d for page Down ";
  126.  
  127.  
  128.  
  129. ' now wait for keypress to page up or page down   and handle it
  130. getpage:
  131. pageDir$ = ""
  132. WHILE UCASE$(pageDir$) <> "U" AND UCASE$(pageDir$) <> "D"
  133.     pageDir$ = INKEY$
  134.     _LIMIT 60
  135. IF UCASE$(pageDir$) = "U" THEN
  136.     IF page - 40 >= 0 THEN page = page - 40 ELSE BEEP
  137. ELSEIF UCASE$(pageDir$) = "D" THEN
  138.     IF page + 40 <= 2040 THEN page = page + 40 ELSE BEEP
  139.     IF pageDir$ <> "" THEN BEEP
  140.     GOTO getpage
  141. GOTO nextPage
  142.  
  143.  
  144.  
  145. '                a very powerful parsing tool!!!
  146.  
  147. SUB Split (SplitMeString AS STRING, delim AS STRING, loadMeArray() AS STRING)
  148.     DIM curpos AS LONG, arrpos AS LONG, LD AS LONG, dpos AS LONG 'fix use the Lbound the array already has
  149.     curpos = 1: arrpos = LBOUND(loadMeArray): LD = LEN(delim)
  150.     dpos = INSTR(curpos, SplitMeString, delim)
  151.     DO UNTIL dpos = 0
  152.         loadMeArray(arrpos) = MID$(SplitMeString, curpos, dpos - curpos)
  153.         arrpos = arrpos + 1
  154.         IF arrpos > UBOUND(loadMeArray) THEN REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO UBOUND(loadMeArray) + 1000) AS STRING
  155.         curpos = dpos + LD
  156.         dpos = INSTR(curpos, SplitMeString, delim)
  157.     LOOP
  158.     loadMeArray(arrpos) = MID$(SplitMeString, curpos)
  159.     REDIM _PRESERVE loadMeArray(LBOUND(loadMeArray) TO arrpos) AS STRING 'get the ubound correct
  160.  
  161.  
  162.  
  163. 'hint   to color code writing
  164. 'FOR i = 0 TO 15
  165. '    PRINT HEX$(i), VAL("&H" + HEX$(i))
  166. 'NEXT
  167.  
  168.  


  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Sequence
Post by: carloscordeiro on September 24, 2020, 08:12:43 am
Hi Bplus, that's exactly what I want, now I made a big mistake. I was not careful to mention that the file seque.txt is cumulative. You've done a lot, I'm ashamed to ask you for something more.

I'll leave it as is, with two steps.

From the beginning, I really liked the scroll bar "u for Up" and "d for page Down" that you inserted in your code.
At night I will put the frame with lines.

Thank you very much

Carlos
Title: Re: Sequence
Post by: bplus on September 24, 2020, 10:41:21 am
Hi Bplus, that's exactly what I want, now I made a big mistake. I was not careful to mention that the file seque.txt is cumulative. You've done a lot, I'm ashamed to ask you for something more.

I'll leave it as is, with two steps.

From the beginning, I really liked the scroll bar "u for Up" and "d for page Down" that you inserted in your code.
At night I will put the frame with lines.

Thank you very much

Carlos

If you are asking for cumulative totals on the sequence lengths, they are already there in the analysis file. It is from that that I find the totals for the line (though I could do it from the color coding 15 character string that's more work).

This solution done in 2 steps makes it easier to follow the coding logic. After the analysis is done, you don't need original data file and you can then concentrate on how you want the data displayed.

Title: Re: Sequence
Post by: carloscordeiro on September 24, 2020, 09:31:33 pm
Okay, thanks again for your attention and dedication to helping.