Adress of different elements in a table

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
LILY

Adress of different elements in a table

Post by LILY »

Can somebody tells me how I can get the address of each elements of a table 4X4?
User avatar
Levi
Veteran
Posts: 79
Joined: Tue Jul 27, 2004 11:44 pm
Location: Alone and forgotten
Contact:

Post 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.
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
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post 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.
"But...It was so beutifully done"
LILY

ADDRESS of each letter in this table

Post 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?
Guest

Post 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
LILY

Poke elements of a table

Post by LILY »

Thanks for help.should may be work but my GWBASIC refuses the
DEF VARSEG(A$(0,0))
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post 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?! :?
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post 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.
"But...It was so beutifully done"
LILY

Table elements adress

Post 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?
LILY

Changing with POKE elements in a table

Post 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...)
Post Reply