|
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |
1. Selecting objects? #3834 |
I don't know if that was a good title to the post, but to the point... I'm trying to make a chess program/server, but I'm not sure how I can refer to a specific stringgrid (to store piece locatoin , for example), without doing something like this...
SELECT CASE grid$
CASE IS = "1"
StringGrid1.Cell(1,1) = "WP"
CASE IS = "2"
StringGrid2.Cell(1,1) = "WP"
CASE IS = "3"
StringGrid3.Cell(1,1) = "WP"
etc...
END SELECT
Of course, I would go with this if naming one specific cell was all I needed, but it has to be a code where stuff depends on other variables... I don't want to have 5 different copies of the same code or something...
Is there like a way to assign them an array, like in
DIM piece(8) AS STRING
or something?
|
2. Re: Selecting objects? #3843 Posted by: 2004-04-15 21:42:24 |
not clear about the condition you want to handle. but you could simplify the CASE by doing this:
SELECT CASE grid$
CASE "1","2","3","4", ..
StringGrid2.Cell(1,1) = "WP"
etc..
CASE ELSE
code..
END SELECT
while for array you could use DEFSTR, DEFINT, DEFLNG, DEFBYTE, ... to define group or specific numbers or string such as:
DEFSTR piece(1 TO 8) = {"1","2","3","4",...,"8"}
hope it helps...
|
3. Re: Selecting objects? #3844 Posted by: 2004-04-15 21:48:01 |
sorry, a typo in array example above. here the correction:
DEFSTR piece(1 TO 8) = {"1","2","3","4",...,"8"}
|
4. Re: Selecting objects? #3845 Posted by: 2004-04-15 21:52:12 |
Guidance,
Something wrong with your code syntax processor in this forum. it put the quote (") symbol before the bracket ({) even I type it right. now I'm type it without using "code" handler:
DEFSTR piece(1 TO 8) = {"1","2","3","4",...,"8"}
|
5. Re: Selecting objects? #3850 |
I mean... if I had 3 different stringgrids, is there a way to say do StringGrid(n), where n is a number from 1 to 3, so i could do something like
StringGrid(n).Cell(1,3) = "blah"
instead of
SELECT CASE grid$
CASE IS = "1"
StringGrid1.Cell(1,3) = "blah"
etc...
END SELECT
I mean, I only want it into ONE of the stringgrids, and that specific one is specified by the variable grid$. |
6. Re: Selecting objects? #3857 |
The bug fixed. Thanks very much!
You mean, DIM stringgrid(8) AS QSTRINGGRID
doesn't work? As far as I know, RQ doesn't support dim as array for all QObjects. |
7. Re: Selecting objects? #3859 Posted by: 2004-04-17 01:03:23 |
DIMming multiple StringGrids doesn't work in my experience, but you could use multi-dimensional arrays to reference different areas of one StringGrid.
E.g. DIM Array(2, x, y) and use the grid as below: <-- x --> <-- x --> <-- x --> y +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |0|0|0|0|0|1|1|1|1|1|2|2|2|2|2| | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |0|0|0|0|0|1|1|1|1|1|2|2|2|2|2| | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ V |
8. Re: Selecting objects? #3862 |
Which QObjects can actually be arrayed?
|
9. Re: Selecting objects? #3863 Posted by: 2004-04-17 08:48:34 |
Apart from the global components, like Clipboard, Printer, etc., just about all the normal 'building block' components apart from StringGrids and File/MemoryStreams, although ISTR that there's a workaround somewhere on the site for the latter. It's also not possible with extended objects. |
10. Re: Selecting objects? #3865 |
So would you just do it like you do a normal variable? |
11. Re: Selecting objects? #3867 Posted by: 2004-04-18 18:37:29 |
DECLARE SUB Setup
DIM Panel(4) AS QPANEL DIM Edit(3) AS QEDIT DIM RDB(3) AS QRADIOBUTTON
CREATE Form AS QFORM OnShow = Setup Center ShowModal END CREATE
SUB Setup FOR A% = 0 TO 4 Panel(A%).Parent = Form Panel(A%).Top = A% * 53 Panel(A%).Height = 53 IF A% = 4 THEN Panel(A%).Align = 4 Panel(A%).Width = 125 END IF NEXT FOR A% = 0 TO 3 Edit(A%).Parent = Panel(4) Edit(A%).Align = 1 Edit(A%).Text = STR$(A%) RDB(A%).Parent = Panel(2) RDB(A%).Top = 20 RDB(A%).Left = A% * 45 + 5 RDB(A%).Width = 40 RDB(A%).Caption = CHR$(65 + A%) NEXT END SUB
|
12. Re: Selecting objects? #3872 |
Thanks!!! |
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |