Author Topic: Dalota language program  (Read 3440 times)

0 Members and 1 Guest are viewing this topic.

Offline Larryrl

  • Newbie
  • Posts: 26
    • View Profile
Dalota language program
« on: April 13, 2020, 12:43:48 am »
I have a program to help me edit and upkeep my Dalota conlang. The file loading routine is like this

Code: QB64: [Select]
  1. DIM language$(20000, 2)
  2.  
  3. OPEN "f:\dalota\dalota wordlist.dalwd" FOR INPUT AS #1
  4.  
  5. x = 0
  6.     x = x + 1
  7.     LINE INPUT #1, language$(x, 1)
  8.     LINE INPUT #1, language$(x, 2)
  9.  
  10.  
  11. total = x
  12.  
  13.  

From there it displays the array elements to the screen with column 1 on the left, and column 2 on the right. What I am needing now, is a way to possibly use a loop to go through the data, and change the color of my highlight bar if a word is shown to be a duplicate of another entry. In Excel, they call that cell highlighting. I would love to be able to have duplicates in column a, highlighted and also the dupes in column B. Duplicates across columns is ok.
 

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Dalota language program
« Reply #1 on: April 13, 2020, 05:15:41 pm »
Something like this?

Code: QB64: [Select]
  1. DIM x$(6)
  2. x$(1) = "turtle"
  3. x$(2) = "cat"
  4. x$(3) = "dog"
  5. x$(4) = "cat"
  6. x$(5) = "Rabbit"
  7. x$(6) = "frog"
  8.  
  9. FOR i = 1 TO 6
  10.     PRINT x$(i)
  11. LOCATE 1, 1
  12. GOSUB display_routine
  13.     DO
  14.         _LIMIT 30
  15.         b$ = INKEY$
  16.         IF b$ = CHR$(0) + "H" AND CSRLIN > 1 THEN PRINT x$(CSRLIN);: LOCATE CSRLIN - 1, 1: EXIT DO ' Arrow key up.
  17.         IF b$ = CHR$(0) + "P" AND CSRLIN < 6 THEN PRINT x$(CSRLIN);: LOCATE CSRLIN + 1, 1: EXIT DO ' Arrow key down.
  18.         IF b$ = CHR$(27) THEN END
  19.     LOOP
  20.     GOSUB display_routine
  21.  
  22. display_routine:
  23. j = 0
  24. FOR k = 1 TO 6
  25.     IF x$(CSRLIN) = x$(k) THEN j = j + 1
  26.     IF j = 2 THEN EXIT FOR
  27. IF j = 2 THEN COLOR 14, 4 ELSE COLOR 15, 1
  28. LOCATE , 1
  29. COLOR 7, 0
  30.  

Use arrow up and down to highlight text. Blue is single occurrence. Red is two or more.

Let me know if you don't understand what's happening in the code.

Oh, if you are familiar with INSTR, you could concatenate all of those arrays and do something a little faster than looping...

Code: QB64: [Select]
  1. DIM x$(6)
  2. x$(1) = "turtle"
  3. x$(2) = "cat"
  4. x$(3) = "dog"
  5. x$(4) = "cat"
  6. x$(5) = "Rabbit"
  7. x$(6) = "frog"
  8.  
  9. concat_x$ = "|"
  10. FOR i = 1 TO 6
  11.     PRINT x$(i)
  12.     concat_x$ = concat_x$ + x$(i) + "|"
  13. LOCATE 1, 1
  14. GOSUB display_routine
  15.     DO
  16.         _LIMIT 30
  17.         b$ = INKEY$
  18.         IF b$ = CHR$(0) + "H" AND CSRLIN > 1 THEN PRINT x$(CSRLIN);: LOCATE CSRLIN - 1, 1: EXIT DO ' Arrow key up.
  19.         IF b$ = CHR$(0) + "P" AND CSRLIN < 6 THEN PRINT x$(CSRLIN);: LOCATE CSRLIN + 1, 1: EXIT DO ' Arrow key down.
  20.         IF b$ = CHR$(27) THEN END
  21.     LOOP
  22.     GOSUB display_routine
  23.  
  24. display_routine:
  25. j = 0
  26. x$ = "|" + x$(CSRLIN) + "|"
  27. IF INSTR(INSTR(concat_x$, x$) + LEN(x$), concat_x$, x$) THEN COLOR 14, 4 ELSE COLOR 15, 1
  28. LOCATE , 1
  29. COLOR 7, 0
  30.  

Pete
« Last Edit: April 13, 2020, 05:39:46 pm by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Larryrl

  • Newbie
  • Posts: 26
    • View Profile
Re: Dalota language program
« Reply #2 on: April 27, 2020, 01:33:06 am »
Thanks a lot, that looks awesome. Either one is fast on my machine.

However, I have two versions of this program, one in qb64 and the other in Liberty basic. If I can take this code and modify it to fit the program coded in Liberty basic, that will be good. Not the color part, just the dupes part. I have two arrays ldup$ for the language words and edup$ for the English words. It should check for duplicates on both columns of the array. I need to know if there are two English words thesame, and aso if two langiage words are the same. If language duplicates are found they get added to ldup$ array, if English duplicates are found, they get added to edup$ array. In the Liberty version of the program, I just dump the two dup arrays ldup$ and edup$ into a textbox and can go through them at my leisure. Yes, please explain how this works. I think I know, bit but at the same time I am not totally sure. Also, rather my original request to change the highlight bar, it should color the dupes, in the list to show at all times and I can recheck as needed when I delete some of the dups.