Adress of different elements in a table
Adress of different elements in a table
Can somebody tells me how I can get the address of each elements of a table 4X4?
ummm...what do you mean? What kind of table? An HTML table, a word table, a matricie table. A variable table. Kind of hard to help you get the location of a table if we don't know the type of table or how it's organized. Some go row to column others go column to row.
Unless someone else knows what you're talking about we'll need more info please.
Unless someone else knows what you're talking about we'll need more info please.
Later days,
Matthew
May those who love us love us
And those who don't
May the good Lord turn their hearts
And if he doesn't
May he turn their ankles
So we'll know them by their limping
-Irish prayer
Matthew
May those who love us love us
And those who don't
May the good Lord turn their hearts
And if he doesn't
May he turn their ankles
So we'll know them by their limping
-Irish prayer
- Mitth'raw'nuruodo
- Veteran
- Posts: 839
- Joined: Sat Jan 22, 2005 11:04 am
- Location: Eastern Coast of US
- Contact:
This is QB forum so I think lily is talking about a matrix 4X4.
I'll assume lily's talking about getting the variable at a certain element.
In that case: matrixname(2,4) will get the value at row 2 column 4, assuming it is dim matrixname(1 to 4, 1 to 4).
Make your question better, if you want more help, remeber questions are many, answers are few, ask the right question and you'll get the right answer.
I'll assume lily's talking about getting the variable at a certain element.
In that case: matrixname(2,4) will get the value at row 2 column 4, assuming it is dim matrixname(1 to 4, 1 to 4).
Make your question better, if you want more help, remeber questions are many, answers are few, ask the right question and you'll get the right answer.
"But...It was so beutifully done"
ADDRESS of each letter in this table
10 DIM A$(4,4)
20 DATA A,B,C,D
30 DATA E,F,G,H
40 DATA I,J,K,L
50 DATA M,N,O,P
55 FOR I=1 TO 4
58 FOR J=1 TO 4
60 READ A$(I,J)
90 NEXT J:NEXT I :FOR I=1 TO 4
100 PRINT A$(I,1),A$(I,2),A$(I,3),A$(I,4)
110 NEXT I
How can I get the adress of each one of the letters used in this table in order to be able to modify each of them by POKE?
20 DATA A,B,C,D
30 DATA E,F,G,H
40 DATA I,J,K,L
50 DATA M,N,O,P
55 FOR I=1 TO 4
58 FOR J=1 TO 4
60 READ A$(I,J)
90 NEXT J:NEXT I :FOR I=1 TO 4
100 PRINT A$(I,1),A$(I,2),A$(I,3),A$(I,4)
110 NEXT I
How can I get the adress of each one of the letters used in this table in order to be able to modify each of them by POKE?
DEF VARSEG(A$(0,0))
Poke VARPTR(A$(0,0)), Whatever
will allow you to poke to element (0,0) of A$
DEF VARSEG(A$(1,2))
Poke VARPTR(A$(1,2)), Whatever
will allow you to poke to element (1,2) of A$
etc...
VARSEG returns the segment of the variable you pass to it
VARPTR returns the offset of the variable you pass to it.
The two combined are the address.
to set the segment DEF SEG = segement
to poke/peek to an offset Poke offset, whatever or whatever = Peek(offset)
matt
Poke VARPTR(A$(0,0)), Whatever
will allow you to poke to element (0,0) of A$
DEF VARSEG(A$(1,2))
Poke VARPTR(A$(1,2)), Whatever
will allow you to poke to element (1,2) of A$
etc...
VARSEG returns the segment of the variable you pass to it
VARPTR returns the offset of the variable you pass to it.
The two combined are the address.
to set the segment DEF SEG = segement
to poke/peek to an offset Poke offset, whatever or whatever = Peek(offset)
matt
Poke elements of a table
Thanks for help.should may be work but my GWBASIC refuses the
DEF VARSEG(A$(0,0))
DEF VARSEG(A$(0,0))
- Mitth'raw'nuruodo
- Veteran
- Posts: 839
- Joined: Sat Jan 22, 2005 11:04 am
- Location: Eastern Coast of US
- Contact:
Table elements adress
GWBASIC is my first language and the program I want to modify is written with it.It's a good easy language .Quite similar to QB except some instructions which are different and therefore necessary to replace by additionnal lines of code.So this DEF SEG= VARSEG(A$(0,0)) is not recognized. The program answers: "Type mismatch". I unfortunately believe that for the program to work it would be necessary to give the actual adresses of elements as in the following:
20 DEF SEG
30 X$="DEP"
40 AD=VARPTR(X$)
60 ACH=PEEK(AD+2)*256+PEEK(AD+1)
80 FOR I=ACH TO ACH+PEEK(AD)
110 NEXT I
120 POKE (4736) ,(68)
122 POKE (4737),(79)
123 POKE (4738),(80)
130 PRINT X$
You see the line 60 ?
So how can I get the adress of element 0,0 for instance?
20 DEF SEG
30 X$="DEP"
40 AD=VARPTR(X$)
60 ACH=PEEK(AD+2)*256+PEEK(AD+1)
80 FOR I=ACH TO ACH+PEEK(AD)
110 NEXT I
120 POKE (4736) ,(68)
122 POKE (4737),(79)
123 POKE (4738),(80)
130 PRINT X$
You see the line 60 ?
So how can I get the adress of element 0,0 for instance?
Changing with POKE elements in a table
SOrry to come back, but it doesn't work, whatever language i use. I would like to see a complete working code stating with my table (A,B,C...etc) changing any element in another one (any)
If somebody has time to try it I guess it would help me to go on
QB welcome,of course
(If already sent,sorry,line cuts...)
If somebody has time to try it I guess it would help me to go on
QB welcome,of course
(If already sent,sorry,line cuts...)