Author Topic: Sequence  (Read 7328 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sequence
« Reply #15 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 :(

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Sequence
« Reply #16 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,
 
* Sequencia.txt.txt (Filesize: 8.25 KB, Downloads: 141)
* seque.txt (Filesize: 91.15 KB, Downloads: 124)
« Last Edit: September 23, 2020, 07:21:53 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sequence
« Reply #17 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.

« Last Edit: September 24, 2020, 10:11:54 am by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Sequence
« Reply #18 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
Tela.jpg
* Tela.jpg (Filesize: 488.08 KB, Dimensions: 997x1053, Views: 229)
* Sequencia_2.bas (Filesize: 8.23 KB, Downloads: 121)
« Last Edit: September 23, 2020, 08:54:40 pm by carloscordeiro »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sequence
« Reply #19 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?

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Sequence
« Reply #20 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)))

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Sequence
« Reply #21 on: September 23, 2020, 09:00:36 pm »
Yes, exactly that

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sequence
« Reply #22 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:
 
seq analysis.PNG


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.
« Last Edit: September 23, 2020, 10:21:59 pm by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Sequence
« Reply #23 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?
Tela_02.jpg
* Tela_02.jpg (Filesize: 279.36 KB, Dimensions: 860x693, Views: 250)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sequence
« Reply #24 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.  
« Last Edit: September 23, 2020, 11:53:39 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sequence
« Reply #25 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.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sequence
« Reply #26 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.  


 
Carlos show.PNG

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Sequence
« Reply #27 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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Sequence
« Reply #28 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.

« Last Edit: September 24, 2020, 10:42:31 am by bplus »

Offline carloscordeiro

  • Forum Regular
  • Posts: 102
    • View Profile
Re: Sequence
« Reply #29 on: September 24, 2020, 09:31:33 pm »
Okay, thanks again for your attention and dedication to helping.