Page 1 of 1

Adress of different elements in a table

Posted: Wed Mar 16, 2005 9:23 am
by LILY
Can somebody tells me how I can get the address of each elements of a table 4X4?

Posted: Wed Mar 16, 2005 1:17 pm
by Levi
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.

Posted: Wed Mar 16, 2005 4:36 pm
by Mitth'raw'nuruodo
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.

ADDRESS of each letter in this table

Posted: Thu Mar 17, 2005 6:30 am
by LILY
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?

Posted: Thu Mar 17, 2005 7:34 am
by Guest
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 elements of a table

Posted: Fri Mar 18, 2005 5:42 am
by LILY
Thanks for help.should may be work but my GWBASIC refuses the
DEF VARSEG(A$(0,0))

Posted: Fri Mar 18, 2005 3:52 pm
by Nodtveidt
It's not DEF VARSEG(A$(0,0)), it's DEF SEG = VARSEG(A$(0,0))

And why the hell are you using GWBASIC?! :?

Posted: Sun Mar 20, 2005 9:50 am
by Mitth'raw'nuruodo
GWBASIC....never hear of it....well not true, I've heard a mention here and there but thats it. What it is?

Anyways if you what the limits of DOS use QB.
If you don't use FB.

Table elements adress

Posted: Mon Mar 21, 2005 3:42 am
by LILY
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?

Changing with POKE elements in a table

Posted: Wed Mar 23, 2005 8:29 am
by LILY
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...)