[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2007-06-16T13:34:56-05:00 http://www.petesqbsite.com/phpBB3/app.php/feed/topic/2021 2007-06-16T13:34:56-05:00 2007-06-16T13:34:56-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=14330#p14330 <![CDATA[Strings equaling another string??]]>
However, your code doesn't even try to make BARCOLOR$ be a pointer to NREDFG$. All it does is generate the name of NREDFG$, which wouldn't work in C, either:

Code:

/* phpBB f?cked up the #includes, so I'm leaving * them out. phpBB sucks. */#define COLOR "RED"main() {  const char *NREDFG = "\001N\001R";  char BARCOLOR[30];  const char *INTENSITY1 = "NORMAL";  /* Let's attempt to access NREDFG based on its   * name.   */  /* Build a string into BARCOLOR */  BARCOLOR[0] = INTENSITY1[0];  BARCOLOR[1] = 0;  strcat(BARCOLOR, COLOR);  strcat(BARCOLOR, "FG");  /* Whoops! */  printf("%s\n", BARCOLOR);}
Output:
<pre>
NREDFG
</pre>

What you want to do instead is build an array into which you can index based on the values found in your input. Taking advantage of what little support QB has for structured programming, you could create a FUNCTION that takes "NORMAL", "BRIGHT", etc as an argument and returns a number. You would do the same for color names. Then, you set up a 2-dimensional array that contains all the NREDFG$-like strings:

Code:

' Assuming that you're going to support three intensities ("DIM",' "NORMAL", and "BRIGHT") and 16 colors. The numbers' in the DIM statement are maximum array subscripts, rather' than sizes.DIM colorTable(2, 15) AS STRING' Populate the table.colorTable(0,0) = CHR$(1)+"D"+CHR$(1)+"B"colorTable(1,0) = CHR$(1)+"N"+CHR$(1)+"B"' Etc...
Access to this table might look like this:

Code:

DIM colorCode AS STRINGcolorCode = colorTable(getIntensity%(INTENSITY$), getColor%(BARCOLOR$))
In the event that $INTENSITY="NORMAL" and BARCOLOR$="RED", colorCode will then be identical to $NREDFG.
________
Dodge Hornet

Statistics: Posted by historian — Sat Jun 16, 2007 1:34 pm


]]>
2007-03-01T11:57:33-05:00 2007-03-01T11:57:33-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=14203#p14203 <![CDATA[Strings equaling another string??]]>

Code:

BARCOLOR$ = NREDFG$
And yes, I'm aware this isnt waht you asked.
In FreeBASIC you can use pointers

Statistics: Posted by Z!re — Thu Mar 01, 2007 11:57 am


]]>
2007-03-01T09:02:18-05:00 2007-03-01T09:02:18-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=14202#p14202 <![CDATA[Strings equaling another string??]]> Statistics: Posted by Skyler — Thu Mar 01, 2007 9:02 am


]]>
2006-12-09T22:00:45-05:00 2006-12-09T22:00:45-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=13459#p13459 <![CDATA[Strings equaling another string??]]>
I read an input from a file to determine an intensity and color to be used.. In this example, the line is read into a strings named INTENSITY1$ BARCOLOR$ and is "NORMAL" and "RED"

INTENSITY1$ ="NORMAL"
BARCOLOR$ ="RED"


I build the color string to be used... When it is all said and done. The output of this will be NREDFG$

BARCOLOR$= LEFT$(INTENSITY3$,1)+LTRIM$(RTRIM$(BARCOLOR$))+"FG$"

Now I am definine what exactly a NREDFG$ is... To the file I am writing, I need NREDFG$ to actually be CHR$(001)NCHR$(001)R so I have the following line next...

NREDFG$= CHR$(001)+"N"+CHR$(001)+"R"

When I do a PRINT NREDFG$ if comes out exactly how I want, BUT when I do a PRINT BARCOLOR$ is actually uses NREDFG$....

How can I make the BARCOLOR$ point to NREDFG$ instead of literally printing NREDFG$ ??? In C programming I can use a pointer to it... how do I do this in my example?

Statistics: Posted by Mike Alexander — Sat Dec 09, 2006 10:00 pm


]]>