Author Topic: BBS Color Screen Creator Program problems  (Read 6032 times)

0 Members and 1 Guest are viewing this topic.

Offline rcamp48

  • Newbie
  • Posts: 62
    • View Profile
BBS Color Screen Creator Program problems
« on: September 15, 2020, 01:59:35 pm »
Code: QB64: [Select]
  1.  

Hello everyone :

I am in the process of writing code for a BBS screen creator, I have all of the code up on Github, but I am having problems with changing the colors of the display on the screen properly. The idea for the code for that part is that either the color changes or it does not. I will put in just the code that I use for displaying the text in color , I am reading in a text file and writing out @BBS codes, K-codes, Sauce and ANSI codes , those I have down but would like to convert a lot of it to case select and functions.

I have been programming for over 40 years but just have started to learn how to use functions with case select.

Here is the effected code:

DO UNTIL EOF(1)

    LINE INPUT #1, lnumber

    FOR i = 1 TO LEN(lnumber)

        b = MID$(lnumber, i, 1) ' Calculates the ascii value of every character in the line
        IF display = "ansi" THEN
            GOSUB specialcharacters3
            GOSUB specialcharacters2
            IF flag$ = "Y1" THEN
                GOSUB colorchange
                COLOR t1, g1
                x = g1
                y = t1
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcoloransi + foregroundcoloransi + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y2" THEN
                GOSUB colorchange
                COLOR t2, g2
                x = g2
                y = t2
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcoloransi + foregroundcoloransi + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y3" THEN
                GOSUB colorchange
                COLOR t, g
                x = g
                y = t
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcoloransi + foregroundcoloransi + b;
                    PRINT b;
                END IF
            ELSE
                IF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
        END IF

        IF display = "wc8" THEN
            GOSUB specialcharacters3
            GOSUB specialcharacters2
            IF flag$ = "Y1" THEN
                GOSUB colorchange
                x = g1
                y = t1
                COLOR t1, g1
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorbbs + foregroundcolorbbs + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y2" THEN
                GOSUB colorchange
                x = g2
                y = t2
                COLOR t2, g2
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorbbs + foregroundcolorbbs + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y3" THEN
                GOSUB colorchange
                x = g
                y = t
                COLOR t, g
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorbbs + foregroundcolorbbs + b;
                    PRINT b;
                END IF
            ELSE
                IF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
        END IF
        IF display = "pcb" THEN
            GOSUB specialcharacters3
            GOSUB specialcharacters2
            IF flag$ = "Y1" THEN
                GOSUB colorchange
                COLOR t1, g1
                x = g1
                y = t1
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorpcb + foregroundcolorpcb + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y2" THEN
                GOSUB colorchange
                COLOR t2, g2
                x = g2
                y = t2
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorpcb + foregroundcolorpcb + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y3" THEN
                GOSUB colorchange
                COLOR t, g
                x = g
                y = t
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorpcb + foregroundcolorpcb + b;
                    PRINT b;
                END IF
            ELSE
                IF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
        END IF
        IF display = "synchro" THEN
            GOSUB specialcharacters3
            GOSUB specialcharacters2
            IF flag$ = "Y1" THEN
                GOSUB colorchange
                COLOR t1, g1
                x = g1
                y = t1
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorsynchro + foregroundcolorsynchro + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y2" THEN
                GOSUB colorchange
                COLOR t2, g2
                x = g2
                y = t2
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorsynchro + foregroundcolorsynchro + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y3" THEN
                GOSUB colorchange
                COLOR t, g
                x = g
                y = t
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolorsynchro + foregroundcolorsynchro + b;
                    PRINT b;
                END IF
            ELSE
                IF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
        END IF
        IF display = "mystic" THEN
            GOSUB specialcharacters3
            GOSUB specialcharacters2
            IF flag$ = "Y1" THEN
                GOSUB colorchange
                COLOR t1, g1
                x = g1
                y = t1
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolormystic + foregroundcolormystic + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y2" THEN
                GOSUB colorchange
                COLOR t2, g2
                x = g2
                y = t2
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolormystic + foregroundcolormystic + b;
                    PRINT b;
                ELSEIF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
            IF flag$ = "Y3" THEN
                GOSUB colorchange
                COLOR t, g
                x = g
                y = t
                GOSUB displ
                IF colorchanges = 1 THEN
                    PRINT #2, backgroundcolormystic + foregroundcolormystic + b;
                    PRINT b;
                END IF
            ELSE
                IF colorchanges = 0 THEN
                    PRINT #2, b;
                    PRINT b;
                END IF
            END IF
        END IF
    NEXT i
    PRINT #2, ""
    PRINT
LOOP
fini:
closeit:
CLOSE #1
PRINT #2, "@0" + "7@";
COLOR 7, 0
IF menuchoice = "M" THEN
    DO UNTIL EOF(3)
        LINE INPUT #3, lnumber
        PRINT #2, lnumber
        PRINT lnumber
    LOOP
ELSE
END IF
PRINT #2, "@0" + "7@"
CLOSE #2
CLOSE #3
COLOR 7, 0
PRINT
PRINT " Create another screen ? [Defaults to [Y]es : "
answer = INPUT$(1)
answer = UCASE$(answer)
IF answer = "N" THEN
    GOSUB create
    GOTO finish
ELSE
    contlne = 0
    CLEAR
    GOTO rand

END IF

finish:


and the part that actually does the work:

colorchange:
IF flag$ = "Y1" THEN
    g1 = x1
    t1 = y1
    colorchanges = 1
ELSEIF flag$ = "Y2" THEN
    g2 = x2
    t2 = y2
    colorchanges = 1
ELSEIF flag$ = "Y3" THEN
    g = z
    t = q
    colorchanges = 1
ELSE
    g = z
    t = q
    colorchanges = 0
END IF
RETURN

This is just part of the code that I am having problems with , if I use numbers in the g1,t1,g2,t2,g,t variables it will work, but if I use a variable as the data for the initial variables , the program will not work. Any suggestions?

Russ Campbell

https://github.com/rcamp48/BBS-Screen-Menu-Creator-for-All-BBSs-Version-13-Beta-Release

Russ Campbell
rcamp48@rogers.com
BBS Files Programmer

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #1 on: September 15, 2020, 02:38:37 pm »
Code: QB64: [Select]
  1.  

Hello everyone :

I am in the process of writing code for a BBS screen creator, I have all of the code up on Github, but I am having problems with changing the colors of the display on the screen properly. The idea for the code for that part is that either the color changes or it does not. I will put in just the code that I use for displaying the text in color , I am reading in a text file and writing out @BBS codes, K-codes, Sauce and ANSI codes , those I have down but would like to convert a lot of it to case select and functions.

I have been programming for over 40 years but just have started to learn how to use functions with case select.

Here is the effected code:

Code: QB64: [Select]
  1.  
  2.     LINE INPUT #1, lnumber
  3.  
  4.     FOR i = 1 TO LEN(lnumber)
  5.  
  6.         b = MID$(lnumber, i, 1) ' Calculates the ascii value of every character in the line
  7.         IF display = "ansi" THEN
  8.             GOSUB specialcharacters3
  9.             GOSUB specialcharacters2
  10.             IF flag$ = "Y1" THEN
  11.                 GOSUB colorchange
  12.                 COLOR t1, g1
  13.                 x = g1
  14.                 y = t1
  15.                 GOSUB displ
  16.                 IF colorchanges = 1 THEN
  17.                     PRINT #2, backgroundcoloransi + foregroundcoloransi + b;
  18.                     PRINT b;
  19.                 ELSEIF colorchanges = 0 THEN
  20.                     PRINT #2, b;
  21.                     PRINT b;
  22.                 END IF
  23.             END IF
  24.             IF flag$ = "Y2" THEN
  25.                 GOSUB colorchange
  26.                 COLOR t2, g2
  27.                 x = g2
  28.                 y = t2
  29.                 GOSUB displ
  30.                 IF colorchanges = 1 THEN
  31.                     PRINT #2, backgroundcoloransi + foregroundcoloransi + b;
  32.                     PRINT b;
  33.                 ELSEIF colorchanges = 0 THEN
  34.                     PRINT #2, b;
  35.                     PRINT b;
  36.                 END IF
  37.             END IF
  38.             IF flag$ = "Y3" THEN
  39.                 GOSUB colorchange
  40.                 COLOR t, g
  41.                 x = g
  42.                 y = t
  43.                 GOSUB displ
  44.                 IF colorchanges = 1 THEN
  45.                     PRINT #2, backgroundcoloransi + foregroundcoloransi + b;
  46.                     PRINT b;
  47.                 END IF
  48.             ELSE
  49.                 IF colorchanges = 0 THEN
  50.                     PRINT #2, b;
  51.                     PRINT b;
  52.                 END IF
  53.             END IF
  54.         END IF
  55.  
  56.         IF display = "wc8" THEN
  57.             GOSUB specialcharacters3
  58.             GOSUB specialcharacters2
  59.             IF flag$ = "Y1" THEN
  60.                 GOSUB colorchange
  61.                 x = g1
  62.                 y = t1
  63.                 COLOR t1, g1
  64.                 GOSUB displ
  65.                 IF colorchanges = 1 THEN
  66.                     PRINT #2, backgroundcolorbbs + foregroundcolorbbs + b;
  67.                     PRINT b;
  68.                 ELSEIF colorchanges = 0 THEN
  69.                     PRINT #2, b;
  70.                     PRINT b;
  71.                 END IF
  72.             END IF
  73.             IF flag$ = "Y2" THEN
  74.                 GOSUB colorchange
  75.                 x = g2
  76.                 y = t2
  77.                 COLOR t2, g2
  78.                 GOSUB displ
  79.                 IF colorchanges = 1 THEN
  80.                     PRINT #2, backgroundcolorbbs + foregroundcolorbbs + b;
  81.                     PRINT b;
  82.                 ELSEIF colorchanges = 0 THEN
  83.                     PRINT #2, b;
  84.                     PRINT b;
  85.                 END IF
  86.             END IF
  87.             IF flag$ = "Y3" THEN
  88.                 GOSUB colorchange
  89.                 x = g
  90.                 y = t
  91.                 COLOR t, g
  92.                 GOSUB displ
  93.                 IF colorchanges = 1 THEN
  94.                     PRINT #2, backgroundcolorbbs + foregroundcolorbbs + b;
  95.                     PRINT b;
  96.                 END IF
  97.             ELSE
  98.                 IF colorchanges = 0 THEN
  99.                     PRINT #2, b;
  100.                     PRINT b;
  101.                 END IF
  102.             END IF
  103.         END IF
  104.         IF display = "pcb" THEN
  105.             GOSUB specialcharacters3
  106.             GOSUB specialcharacters2
  107.             IF flag$ = "Y1" THEN
  108.                 GOSUB colorchange
  109.                 COLOR t1, g1
  110.                 x = g1
  111.                 y = t1
  112.                 GOSUB displ
  113.                 IF colorchanges = 1 THEN
  114.                     PRINT #2, backgroundcolorpcb + foregroundcolorpcb + b;
  115.                     PRINT b;
  116.                 ELSEIF colorchanges = 0 THEN
  117.                     PRINT #2, b;
  118.                     PRINT b;
  119.                 END IF
  120.             END IF
  121.             IF flag$ = "Y2" THEN
  122.                 GOSUB colorchange
  123.                 COLOR t2, g2
  124.                 x = g2
  125.                 y = t2
  126.                 GOSUB displ
  127.                 IF colorchanges = 1 THEN
  128.                     PRINT #2, backgroundcolorpcb + foregroundcolorpcb + b;
  129.                     PRINT b;
  130.                 ELSEIF colorchanges = 0 THEN
  131.                     PRINT #2, b;
  132.                     PRINT b;
  133.                 END IF
  134.             END IF
  135.             IF flag$ = "Y3" THEN
  136.                 GOSUB colorchange
  137.                 COLOR t, g
  138.                 x = g
  139.                 y = t
  140.                 GOSUB displ
  141.                 IF colorchanges = 1 THEN
  142.                     PRINT #2, backgroundcolorpcb + foregroundcolorpcb + b;
  143.                     PRINT b;
  144.                 END IF
  145.             ELSE
  146.                 IF colorchanges = 0 THEN
  147.                     PRINT #2, b;
  148.                     PRINT b;
  149.                 END IF
  150.             END IF
  151.         END IF
  152.         IF display = "synchro" THEN
  153.             GOSUB specialcharacters3
  154.             GOSUB specialcharacters2
  155.             IF flag$ = "Y1" THEN
  156.                 GOSUB colorchange
  157.                 COLOR t1, g1
  158.                 x = g1
  159.                 y = t1
  160.                 GOSUB displ
  161.                 IF colorchanges = 1 THEN
  162.                     PRINT #2, backgroundcolorsynchro + foregroundcolorsynchro + b;
  163.                     PRINT b;
  164.                 ELSEIF colorchanges = 0 THEN
  165.                     PRINT #2, b;
  166.                     PRINT b;
  167.                 END IF
  168.             END IF
  169.             IF flag$ = "Y2" THEN
  170.                 GOSUB colorchange
  171.                 COLOR t2, g2
  172.                 x = g2
  173.                 y = t2
  174.                 GOSUB displ
  175.                 IF colorchanges = 1 THEN
  176.                     PRINT #2, backgroundcolorsynchro + foregroundcolorsynchro + b;
  177.                     PRINT b;
  178.                 ELSEIF colorchanges = 0 THEN
  179.                     PRINT #2, b;
  180.                     PRINT b;
  181.                 END IF
  182.             END IF
  183.             IF flag$ = "Y3" THEN
  184.                 GOSUB colorchange
  185.                 COLOR t, g
  186.                 x = g
  187.                 y = t
  188.                 GOSUB displ
  189.                 IF colorchanges = 1 THEN
  190.                     PRINT #2, backgroundcolorsynchro + foregroundcolorsynchro + b;
  191.                     PRINT b;
  192.                 END IF
  193.             ELSE
  194.                 IF colorchanges = 0 THEN
  195.                     PRINT #2, b;
  196.                     PRINT b;
  197.                 END IF
  198.             END IF
  199.         END IF
  200.         IF display = "mystic" THEN
  201.             GOSUB specialcharacters3
  202.             GOSUB specialcharacters2
  203.             IF flag$ = "Y1" THEN
  204.                 GOSUB colorchange
  205.                 COLOR t1, g1
  206.                 x = g1
  207.                 y = t1
  208.                 GOSUB displ
  209.                 IF colorchanges = 1 THEN
  210.                     PRINT #2, backgroundcolormystic + foregroundcolormystic + b;
  211.                     PRINT b;
  212.                 ELSEIF colorchanges = 0 THEN
  213.                     PRINT #2, b;
  214.                     PRINT b;
  215.                 END IF
  216.             END IF
  217.             IF flag$ = "Y2" THEN
  218.                 GOSUB colorchange
  219.                 COLOR t2, g2
  220.                 x = g2
  221.                 y = t2
  222.                 GOSUB displ
  223.                 IF colorchanges = 1 THEN
  224.                     PRINT #2, backgroundcolormystic + foregroundcolormystic + b;
  225.                     PRINT b;
  226.                 ELSEIF colorchanges = 0 THEN
  227.                     PRINT #2, b;
  228.                     PRINT b;
  229.                 END IF
  230.             END IF
  231.             IF flag$ = "Y3" THEN
  232.                 GOSUB colorchange
  233.                 COLOR t, g
  234.                 x = g
  235.                 y = t
  236.                 GOSUB displ
  237.                 IF colorchanges = 1 THEN
  238.                     PRINT #2, backgroundcolormystic + foregroundcolormystic + b;
  239.                     PRINT b;
  240.                 END IF
  241.             ELSE
  242.                 IF colorchanges = 0 THEN
  243.                     PRINT #2, b;
  244.                     PRINT b;
  245.                 END IF
  246.             END IF
  247.         END IF
  248.     NEXT i
  249.     PRINT #2, ""
  250.     PRINT
  251. fini:
  252. closeit:
  253. PRINT #2, "@0" + "7@";
  254. COLOR 7, 0
  255. IF menuchoice = "M" THEN
  256.     DO UNTIL EOF(3)
  257.         LINE INPUT #3, lnumber
  258.         PRINT #2, lnumber
  259.         PRINT lnumber
  260.     LOOP
  261. PRINT #2, "@0" + "7@"
  262. COLOR 7, 0
  263. PRINT " Create another screen ? [Defaults to [Y]es : "
  264. answer = INPUT$(1)
  265. answer = UCASE$(answer)
  266. IF answer = "N" THEN
  267.     GOSUB create
  268.     GOTO finish
  269.     contlne = 0
  270.     CLEAR
  271.     GOTO rand
  272.  
  273.  
  274. finish:
  275.  
  276.  
  277. and the part that actually does the work:
  278.  
  279. colorchange:
  280. IF flag$ = "Y1" THEN
  281.     g1 = x1
  282.     t1 = y1
  283.     colorchanges = 1
  284. ELSEIF flag$ = "Y2" THEN
  285.     g2 = x2
  286.     t2 = y2
  287.     colorchanges = 1
  288. ELSEIF flag$ = "Y3" THEN
  289.     g = z
  290.     t = q
  291.     colorchanges = 1
  292.     g = z
  293.     t = q
  294.     colorchanges = 0
  295.  
  296.  
This is just part of the code that I am having problems with , if I use numbers in the g1,t1,g2,t2,g,t variables it will work, but if I use a variable as the data for the initial variables , the program will not work. Any suggestions?

Russ Campbell

https://github.com/rcamp48/BBS-Screen-Menu-Creator-for-All-BBSs-Version-13-Beta-Release



This is how your code starts

Code: QB64: [Select]
  1.  
  2.     LINE INPUT #1, lnumber

Looks like we need a file to test it.

What is this?
Quote
@BBS codes, K-codes, Sauce

SELECT CASE is easy to live without ;-))   
In fact they just said recently it gets translated to IF THEN ELSEIF ELSE blocks behind the scenes.

Quote
if I use numbers in the g1,t1,g2,t2,g,t variables it will work, but if I use a variable as the data for the initial variables , the program will not work.
What does data look like before you made variables and what data are the variables based when it doesn't work?

Github:
Code: QB64: [Select]
  1. SCREEN 12
  2.  

means you are probably using old QB colors with range 0 to 15, correct?

This code snip is useless, where is all this stuff like
Code: QB64: [Select]
  1.             GOSUB specialcharacters3
  2.             GOSUB specialcharacters2
  3.  

Curses to GOSUB this and GOSUB that, can't find 'em fast :(

Make you gosubs real SUBs.


« Last Edit: September 15, 2020, 04:00:12 pm by bplus »

Offline rcamp48

  • Newbie
  • Posts: 62
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #2 on: September 15, 2020, 03:19:49 pm »
I have  a link to the whole program, I am just learning how to use subs and functions plus case select in functions.

https://github.com/rcamp48/BBS-Screen-Menu-Creator-for-All-BBSs-Version-13-Beta-Release

This program link contains everything that you will need , it is a program for changing ascii into color Telnet screens
Russ Campbell
rcamp48@rogers.com
BBS Files Programmer

Offline rcamp48

  • Newbie
  • Posts: 62
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #3 on: September 15, 2020, 03:22:33 pm »
This is what I have started to do to replace the sub-routine "wc8" from if statements to case select

FUNCTION Select_BBS_Screen_Code_Wildcat (x, y)
    x = backgroundcolor
    SELECT CASE backgroundcolor
        CASE 0: wildcat$ = "@0"
        CASE 1: wildcat$ = "@1"
        CASE 2: wildcat$ = "@2"
        CASE 3: wildcat$ = "@3"
        CASE 4: wildcat$ = "@4"
        CASE 5: wildcat$ = "@5"
        CASE 6: wildcat$ = "@6"
        CASE 7: wildcat$ = "@7"
        CASE 8: wildcat$ = "@8"
        CASE 9: wildcat$ = "@9"
        CASE 10: wildcat$ = "@A"
        CASE 11: wildcat$ = "@B"
        CASE 12: wildcat$ = "@C"
        CASE 13: wildcat$ = "@D"
        CASE 14: wildcat$ = "@E"
        CASE 15: wildcat$ = "@F"
    END SELECT
    y = foregroundcolor
    SELECT CASE foregroundcolor
        CASE 0: wildcat$ = "0@"
        CASE 1: wildcat$ = "1@"
        CASE 2: wildcat$ = "2@"
        CASE 3: wildcat$ = "3@"
        CASE 4: wildcat$ = "4@"
        CASE 5: wildcat$ = "5@"
        CASE 6: wildcat$ = "6@"
        CASE 7: wildcat$ = "7@"
        CASE 8: wildcat$ = "8@"
        CASE 9: wildcat$ = "9@"
        CASE 10: wildcat$ = "A@"
        CASE 11: wildcat$ = "B@"
        CASE 12: wildcat$ = "C@"
        CASE 13: wildcat$ = "D@"
        CASE 14: wildcat$ = "E@"
        CASE 15: wildcat$ = "F@"
    END SELECT
END FUNCTION

This will eventually send the right color codes to the output file.

Russ
Russ Campbell
rcamp48@rogers.com
BBS Files Programmer

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #4 on: September 15, 2020, 03:30:50 pm »
Quote
I am just learning how to use subs and functions plus case select in functions.

The time spent here will be well be god sent!

What is Telnet color values? like RGB (giant _unsigned long with or without alpha transparencies) maybe in Hex like QB4.5 red #12 = &HFFFF0000?  in solid 255 alpha.

You are not setting the function.

What do you want the function to return?

Maybe

Code: QB64: [Select]
  1. FUNCTION Wildcat$ (QBnumber)
  2.     SELECT CASE QBnumber ' 0 to 15
  3.         CASE 1: Wildcat$ = "@0" ' this sets the function name to "@0" on return
  4.         CASE 2: Wildcat$ = "@1"
  5.             '     ...  ect, ect
  6.         CASE ELSE: Wildcat$ = "" 'or just space or beep error
  7.     END SELECT


main code program call to function:
myColor$ = Wildcat$(0)  >>> returns "@0" or sets myColor$ to "@0"

If you don't set the function name nothing gets returned.
« Last Edit: September 15, 2020, 03:42:06 pm by bplus »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #5 on: September 15, 2020, 03:36:53 pm »
Just a little note when posting code there should be a little button above the text box with the QB64 logo in it, click on that and it will add a code box in your post so its not super long! just FYI. makes posts easier to read.
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #6 on: September 15, 2020, 03:58:20 pm »
Here is code tag in Forum editor:

  [ You are not allowed to view this attachment ]  

Either select all the code (already pasted into editor) and press code tag button

OR

with code in clipboard press button and insert the paste from clipboards exactly between the 2 square brackets >>>  code=qb64][/code   
« Last Edit: September 15, 2020, 04:13:37 pm by bplus »

Offline rcamp48

  • Newbie
  • Posts: 62
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #7 on: September 15, 2020, 04:26:06 pm »
Just to let you all know what my program does and an explaination of it , I have made up a narrated video that tries to explain everything in the main part of my program. Here is the video:

https://youtu.be/UmfUzw1_mmc

Hope that clears up what I am trying to accomplish.

Russ
Russ Campbell
rcamp48@rogers.com
BBS Files Programmer

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #8 on: September 15, 2020, 06:10:17 pm »
Ok the variables you want to use are for the COLOR statement?

You want to do this:
Code: QB64: [Select]
  1. COLOR var1, var2  

instead of hand coding everything like this?
Code: QB64: [Select]
  1. COLOR 1, 7

Correct? You're saying it works with literal numbers but not with a variable?

It should work if the variables are set to a QB color number 0  to 15:
Code: QB64: [Select]
  1.  SCREEN 12
  2.  
  3.     COLOR 12, 7
  4.     PRINT "Testing color printed"
  5.  
  6.     var1 = RND * 15 + 1: var2 = RND * 15 + 1
  7.  
  8.     COLOR var1, var2
  9.     PRINT "OK testing rnd color selected."
  10.  
  11.  
  12.     INPUT "OK Enter t for another test or quits ", w$
  13.  
  14.  


You know what? In this case I don't advise changing to SUBs and FUNCTIONs until you are familiar with scoping rules.

All the variables you change inside a SUB or FUNCTION are private to that SUB or FUNCTION, your main program can't read those values unless you DIM SHARED the variable names at the beginning of your program or you pass them through the argument list when you call the SUB or FUNCTION.






« Last Edit: September 15, 2020, 06:26:16 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #9 on: September 15, 2020, 06:40:20 pm »
Code: QB64: [Select]
  1. colorchange:
  2. IF flag$ = "Y1" THEN
  3.     g1 = 3
  4.     t1 = 6
  5.     colorchanges = 1
  6. ELSEIF flag$ = "Y2" THEN
  7.     g2 = 6
  8.     t2 = 7
  9.     colorchanges = 1
  10. ELSEIF flag$ = "Y3" THEN
  11.     g = 4
  12.     t = 7
  13.     colorchanges = 1
  14.     g = 4
  15.     t = 7
  16.     colorchanges = 0
  17.  

This is only place you set g1, t1 what variable do you want to set it to?

« Last Edit: September 15, 2020, 06:47:18 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #10 on: September 15, 2020, 08:17:45 pm »
Hi rcamp48
here my two cents:

1.
please remove all those _FULLSCREEN, you need use just one time that instruction to get the full screen state of the window of the program

2.  so you're working in SCREEN 12 as I can read at line 84 of your code (V13)

3. if you like to learn the SUB and the FUNCTION....following that also Bplus has said to you remembering that
     3.1 SUB and FUNCTION  are closed areas of the program that cannot access to main variables and cannot share with main block
            variables  until you declare DIM SHARED variables into main block or SHARED variables into SUB/FUNCTION block or pass
            those variables as a list of variable after the name of SUB/FUNCTION.
      3.2 each SUB  is a block of closed code that starts with SUB NameSub (parameter1 AS typedata, parameter2 AS
            typedata,...parameterN AS typedata) and after few or many lines of codes it finishes with END SUB. 
      Here detailed wiki http://qb64.org/wiki/SUB
      3.3 each FUNCTION  is a block of closed code that starts with SUB NameFunction (parameter1 AS typedata, parameter2 AS
            typedata,...parameterN AS typedata) and after few or many lines of codes  among these there is NameFunction = value and
            it finishes with END FUNCTION.
     Here detailed wiki http://qb64.org/wiki/FUNCTION
     So please close that function at the end of your code with END FUNCTION! (V14)

In the while we can safely translate some code into SUB to make more readable the code....
for example you can write this at the bottom of your code after END FUNCTION (have you typed this line of code?) of V14 or after END at bottom of file  V13.
Code: QB64: [Select]
and then you can change each
Code: QB64: [Select]
with
Code: QB64: [Select]
  1. WaitAKey
and with this you have made your first safe SUB.

Now you can type at the bottom of your file (V13) after the sub WaitAKey this other SUB
Code: QB64: [Select]
  1. SUB SplashScreen
  2. COLOR 14, 12
  3. LOCATE 10, 24
  4. PRINT "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
  5. LOCATE 11, 24
  6. PRINT "%                 BBS Screen Creator Written By Russ Campbell                  %"
  7. LOCATE 12, 24
  8. PRINT "%                                                                              %"
  9. LOCATE 13, 24
  10. PRINT "%                   Beta Version 13  Release Candidate RC2                     %"
  11. LOCATE 14, 24
  12. PRINT "%                                                                              %"
  13. LOCATE 15, 24
  14. PRINT "%                This is a beta release, not everything is working yet         %"
  15. LOCATE 16, 24
  16. PRINT "%                                                                              %"
  17. LOCATE 17, 24
  18. PRINT "%             With fully customisable color sets added to the program.         %"
  19. LOCATE 18, 24
  20. PRINT "%                                                                              %"
  21. LOCATE 19, 24
  22. PRINT "%                    Press any key to continue.............                    %"
  23. LOCATE 20, 24
  24. PRINT "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

and then you cancel the lines of code from 84 to 107 and type at line 84 SplashScreen

Moreover then go at the end of your code and type these lines
Code: QB64: [Select]
  1.  SUB info
  2. COLOR 7, 0
  3. PRINT "BBS Menu Color Scheme Creator Version 13 Final Version RC1"
  4. PRINT "Written by Russ Campbell Updated September 14 2020"
  5. PRINT "First of all design your menus in straight text no colors, etc"
  6. PRINT "Do not put any background colors in either as the program will"
  7. PRINT "Do that for you automatically. Use the following convention"
  8. PRINT "that is laid out in the next display."
  9. PRINT "This program will then take your plain text menu and turn it into"
  10. PRINT "a random colored display, methods will be taken to ensure that"
  11. PRINT "the backgound and text colors do not print the same colors"
  12. PRINT "Take a look and see what you think, it will of course write"
  13. PRINT "out your menus in .BBS and .ANS formats, kind of a neat feature."
  14. PRINT "Don't like what you get? Then run the program again and again"
  15. PRINT "until you get what you like as a menu screen."
  16. PRINT "This is a complicated program, you don't have to use boxes"
  17. PRINT "but for now that is the only shape that my program will"
  18. PRINT "accept. I will print an example of a menu on the screen so"
  19. PRINT "that you know exactly how to use my program with a text drawing."
  20. PRINT "Press any key to continue..."
then cancel the lines of code from 114 to 139 and 112. Type at line 112 info

with these operations you are chunking down your main block of code in so many reusable closed blocks called SUB.
This is the idea behind SUB and FUNCTION, you make little or big blocks of code to use anywhere and anytime, like the pieces of the Lego!
Going forward, type at the bottom of your V13 file these lines of code
Code: QB64: [Select]
  1. SUB MainMenu
  2. PRINT " ^-------------------------------------------------+"
  3. PRINT " !               Main Message Menu                 !"
  4. PRINT " *-------------------&-----------------------------="
  5. PRINT " !       $           !                             !"
  6. PRINT " *-------------------#-----------------------------="
  7. PRINT " ! [C] Check Your Mail   [S] Scan Messages         !"
  8. PRINT " ! [E] Enter New Message [J] Join Conference       !"
  9. PRINT " ! [F] FILE MENU         [U] Update Settings       !"
  10. PRINT " ! [G] Goodbye           [H] Help Level            !"
  11. PRINT " ! [Q] Quit to Main Menu [?] Command Help          !"
  12. PRINT " ! [R] Read Messages                               !"
  13. PRINT " ~-------------------------------------------------%"
  14. PRINT "Pay special attention to the symbols on each corner"
  15. PRINT "They are all different, one for each corner, to work"
  16. PRINT "properly with my program , they must be right. The "
  17. PRINT "rest of the characters also must be right except for"
  18. PRINT "whats in the menu. You can see the other characters"
  19. PRINT "that I use lines and connectors, the program turns"
  20. PRINT "into nice corners and borders, for double corners "
  21. PRINT "and borders, well , you can figure that one out."
and now you delete the lines of code from 143 to 167 and type at line 143 MainMenu.

Well, now we can say that you like spaghetti or spaghetti code for the many GOTOs and GOSUB used in your code. It is not a problem if you are able to mantain the control of the flow of your program, but the intensive use of GOTO, GOSUB/RETURN and DEF FN END DEF is the opposite of the modular programming. So  it is better if you convert your GOTOs into SUB or loops.
for example this code (lines 172 to 187 in V13)
Code: QB64: [Select]
  1. rand:
  2. PRINT "Do you wish to have multi colors randomly chosen for everything"
  3. PRINT "or user set colors for the entire area that makes up all of the "
  4. PRINT "the menus. This can all be used in either displays or menus"
  5. PRINT "Choose [T]est Program [L]oad Color Patterns or [C]reate new Color Patterns"
  6. PRINT "Choose [X] to exit program"
  7. answer = INPUT$(1)
  8. answer = UCASE$(answer)
  9. IF answer = "C" THEN GOTO inputscreen1
  10. IF answer = "L" THEN GOSUB load
  11. IF answer = "T" THEN GOTO inputscreen
  12. IF answer = "X" THEN GOTO finish
  13. GOTO rand
are better coded like SUB
Code: QB64: [Select]
  1.  SUB rand
  2. PRINT "Do you wish to have multi colors randomly chosen for everything"
  3. PRINT "or user set colors for the entire area that makes up all of the "
  4. PRINT "the menus. This can all be used in either displays or menus"
  5. PRINT "Choose [T]est Program [L]oad Color Patterns or [C]reate new Color Patterns"
  6. PRINT "Choose [X] to exit program"
  7. answer = INPUT$(1)
  8. answer = UCASE$(answer)
  9. IF answer = "C" THEN GOTO inputscreen1
  10. IF answer = "L" THEN GOSUB load
  11. IF answer = "T" THEN GOTO inputscreen
  12. IF answer = "X" THEN GOTO finish
(lines 181 and 182 can be summarized into this:  answer = UCASE$(INPUT$(1)) )
you must do the same work for the others GOTO/GOSUB like inputscreen1, load, inputscreen, finish etc etc.

going to your issues:
at lines 520 ad 521 you jump sequentially to
Code: QB64: [Select]
  1.             GOSUB specialcharacters3
  2.             GOSUB specialcharacters2
but then the second GOSUB has no RETURN and it lies on the first GOSUB that is exdccuted sequentially at the same time
Code: QB64: [Select]
  1. specialcharacters2:
  2.  
  3. IF b = CHR$(94) THEN b = corner1
  4. IF b = CHR$(43) THEN b = corner2
  5. IF b = CHR$(37) THEN b = corner3
  6. IF b = CHR$(126) THEN b = corner4
  7. IF b = CHR$(45) THEN
  8.     b = lineconnector
  9. IF b = CHR$(38) THEN
  10.     b = connector1
  11.  
  12. IF b = CHR$(61) THEN
  13.     b = connector2
  14. IF b = CHR$(35) THEN
  15.     b = connector3
  16. IF b = CHR$(42) THEN
  17.     b = connector4
  18. IF b = CHR$(33) THEN
  19.     b = verticalline
  20. specialcharacters3:
  21. IF b = CHR$(94) OR b = CHR$(43) OR b = CHR$(37) OR b = CHR$(126) OR b = CHR$(45) OR b = CHR$(38) OR b = CHR$(35) OR b = CHR$(42) OR b = CHR$(33) OR b = CHR$(61) THEN
  22.     flag$ = "Y1"
  23. ELSEIF b = CHR$(91) OR b = CHR$(93) THEN
  24.     flag$ = "Y2"
  25.     flag$ = "Y3"
Is it a will or a fatality?
and the GOSUB colorchange to become a SUB must have as parameter the variables that it works internally but the same variables are used in other places of the program to set the colors for output.

At the last
about
Code: QB64: [Select]
  1. FUNCTION Select_BBS_Screen_Code_Wildcat (x, y)
  2.     x = backgroundcolor
  3.     SELECT CASE backgroundcolor
  4.         CASE 0: wildcat$ = "@0"
  5.         CASE 1: wildcat$ = "@1"
  6.         CASE 2: wildcat$ = "@2"
  7.         CASE 3: wildcat$ = "@3"
  8.         CASE 4: wildcat$ = "@4"
  9.         CASE 5: wildcat$ = "@5"
  10.         CASE 6: wildcat$ = "@6"
  11.         CASE 7: wildcat$ = "@7"
  12.         CASE 8: wildcat$ = "@8"
  13.         CASE 9: wildcat$ = "@9"
  14.         CASE 10: wildcat$ = "[member=427]A[/member]"
  15.         CASE 11: wildcat$ = "@B"
  16.         CASE 12: wildcat$ = "@C"
  17.         CASE 13: wildcat$ = "@D"
  18.         CASE 14: wildcat$ = "@E"
  19.         CASE 15: wildcat$ = "@F"
  20.     END SELECT
  21.     y = foregroundcolor
  22.     SELECT CASE foregroundcolor
  23.         CASE 0: wildcat$ = "0@"
  24.         CASE 1: wildcat$ = "1@"
  25.         CASE 2: wildcat$ = "2@"
  26.         CASE 3: wildcat$ = "3@"
  27.         CASE 4: wildcat$ = "4@"
  28.         CASE 5: wildcat$ = "5@"
  29.         CASE 6: wildcat$ = "6@"
  30.         CASE 7: wildcat$ = "7@"
  31.         CASE 8: wildcat$ = "8@"
  32.         CASE 9: wildcat$ = "9@"
  33.         CASE 10: wildcat$ = "A@"
  34.         CASE 11: wildcat$ = "B@"
  35.         CASE 12: wildcat$ = "C@"
  36.         CASE 13: wildcat$ = "D@"
  37.         CASE 14: wildcat$ = "E@"
  38.         CASE 15: wildcat$ = "F@"
  39.     END SELECT
there are 2 errors of the same type...
you assign to the parameters passed to the sub a value 0 because the inner variables of the sub are initialized to 0
with this code
x = backgroundcolor you are doing x becomes backgroundcolor... you must write backgroundcolor = x
and so for y = foregroundcolor --> foregroundcolor = y.
Good luck and good coding.


Programming isn't difficult, only it's  consuming time and coffee

Offline rcamp48

  • Newbie
  • Posts: 62
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #11 on: September 15, 2020, 08:36:38 pm »
Thanks I will look into that later on I did not know that specialcharacters3 had no return, thats a typo, it may solve my problems....I have been programming for over 40 years but I still learn something

Russ

PS: with those two functions if I fix them is it easy to access ??? I want to learn how to use functions and subs instead of writing one big long program....
Russ Campbell
rcamp48@rogers.com
BBS Files Programmer

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #12 on: September 15, 2020, 08:50:05 pm »
Hi @TempodiBasic

This is NOT going to work:
Code: QB64: [Select]
  1.  SUB rand
  2. PRINT "Do you wish to have multi colors randomly chosen for everything"
  3. PRINT "or user set colors for the entire area that makes up all of the "
  4. PRINT "the menus. This can all be used in either displays or menus"
  5. PRINT "Choose [T]est Program [L]oad Color Patterns or [C]reate new Color Patterns"
  6. PRINT "Choose [X] to exit program"
  7. answer = INPUT$(1)
  8. answer = UCASE$(answer)
  9. IF answer = "C" THEN GOTO inputscreen1
  10. IF answer = "L" THEN GOSUB load
  11. IF answer = "T" THEN GOTO inputscreen
  12. IF answer = "X" THEN GOTO finish
  13.  

Quote
Thanks I will look into that later on I did not know that specialcharacters3 had no return, thats a typo, it may solve my problems....I have been programming for over 40 years but I still learn something

Oh! actually its specialcharacters2 not 3 that didn't have a RETURN (at least in my copy)
« Last Edit: September 15, 2020, 08:54:23 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #13 on: September 15, 2020, 08:55:44 pm »
Again I ask what variables did you want to set the g's and t's to? here
Code: QB64: [Select]
  1. colorchange:
  2. IF flag$ = "Y1" THEN
  3.     g1 = 3
  4.     t1 = 6
  5.     colorchanges = 1
  6. ELSEIF flag$ = "Y2" THEN
  7.     g2 = 6
  8.     t2 = 7
  9.     colorchanges = 1
  10. ELSEIF flag$ = "Y3" THEN
  11.     g = 4
  12.     t = 7
  13.     colorchanges = 1
  14.     g = 4
  15.     t = 7
  16.     colorchanges = 0
  17.  

You can test what's coming into this part of code by printing them out in a debug session.
« Last Edit: September 15, 2020, 08:57:44 pm by bplus »

Offline rcamp48

  • Newbie
  • Posts: 62
    • View Profile
Re: BBS Color Screen Creator Program problems
« Reply #14 on: September 16, 2020, 08:02:28 am »
I solved the problem , I now have a fully working program, I simply put in the statements in the colorchange area that basically said : g1=g1, g2=g2, and g=g as well as t1=t1 and t2=t2 and t=t then refered to those variables elsewhere in the program, plus the missing return in the specialcharacters2 sub-routine helped conndiderably once I put in that return.

The program works really good now, thanks to you and several other users here, a big thanks goes out to you all.

Russ Campbell
Russ Campbell
rcamp48@rogers.com
BBS Files Programmer