Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / Selecting objects?

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Selecting objects?
#3834
Posted by: Lawrence 2004-04-15 08:22:12
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?

Message2. 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...
Message3. 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"}
Message4. 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"}
Message5. Re: Selecting objects?
#3850
Posted by: Lawrence 2004-04-16 07:58:30
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$.
Message6. Re: Selecting objects?
#3857
Posted by: guidance 2004-04-16 19:44:37
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.
Message7. 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
Message8. Re: Selecting objects?
#3862
Posted by: Lawrence 2004-04-17 07:28:59
Which QObjects can actually be arrayed?
Message9. 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.
 
Message10. Re: Selecting objects?
#3865
Posted by: Lawrence 2004-04-18 12:08:12
So would you just do it like you do a normal variable?
Message11. 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
Message12. Re: Selecting objects?
#3872
Posted by: Lawrence 2004-04-18 23:29:06
Thanks!!!
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥860.00 ·
 
 
¥900.00 ·
 
 
¥810.00 ·
 
 
¥317.00 ·
 
 
¥1,370.00 ·
 
 
¥660.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0