mystery??

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

mystery??

Post by lily »

I come back on my program:

5 CLS

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
115 PRINT
120 DEF SEG = VARSEG(A$(1, 2))
125 POKE VARPTR(A$(1, 2)), (90)
130 FOR L = 1 TO 4
140 PRINT A$(L, 1), A$(L, 2), A$(L, 3), A$(L, 4)
150 NEXT L

It would work in QB7.1 and if somebody is interested, he can copy it and paste it directly in QB7.1 ,the lines numbers do not matter.
What I get is the original table ,except the element A$(1,2),in spite of instruction 125 (POKE etc)
Can somebody explains why the poked value do not writes itself inside the table at the place of the previous "B"???
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

In QB71:
When using strings, use: SSEG and SADD instead of VARSEG and VARPTR

Code: Select all

5 CLS

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
115 PRINT
120 DEF SEG = SSEG(A$(1, 2))
125 POKE SADD(A$(1, 2)), (90)
130 FOR L = 1 TO 4
140 PRINT A$(L, 1), A$(L, 2), A$(L, 3), A$(L, 4)
150 NEXT L

And you dont need line numbers in QB
I have left this dump.
Lily

Mystery...solved

Post by Lily »

Great! The reason why there are line numbers is because the program should be written in GW BASIC. It is really amazing to see that QB 7.1 accepts line numbers as I discovered it!
Now may I again ask something? I would like to find litterature on offset address etc to explain how to play with this:
ACH=PEEK(AD+1)*256+PEEK(AD)
with
AD=VARPTR(X$) X$ being for instance "ABC"

Where can I find a clear complete explanation on that?
LILY

Mystery,end

Post by LILY »

(Added to the previous one)

When I try to use the first program with VARSEG and VARPTR this time in QB4.5 ,I get several letters instead of the one I want. What can be done to elmiminate thes parasits?From where do they come?
Post Reply