X,Y coordinate arrays

Hello I'm a new member here. I'm an Art student in the Netherlands. Started with QBASIC something like a month ago. I'm woking on a project to print computer generated designs for correspondence paper.
It is real big fun but also pretty difficult once in a while (Now at this moment, for example).

OK this is what I got.

I have all my generated text blocks.

But I want to:

- give X,Y coordinates to each character of text block A
- give X,Y coordinates to each character of text block B
(this part I have already almost fixed)

put the X,Y coordinates of blok A & B together. Sort them. So the coordinates will be ordered from row 1 (Y coord) and colum 1(X coord) to row 100 to column 50.
(Uuuuuuuuuhhhmmmmmmmmm...?)

Than the sorted X,Y values have to one by one send to the LOCATE (LOCATE Y%, X%) function.
And then be LPRINT(-ed).
(That's easy. Also got that one. Something like this:
A loop as big as all the characters with LOCATE Y%, X%; LPRINT A&Bcombined$
next i..... bla bla)

So the difficult part for me is put the A & B text blocks together.

Do I have to use array's (DIM). One or Two Dimensional or even three A(1,1,A)???????

You see, I have kind of lost it here at this point. I hope somebody can give me some clues.

Thanks and everyone BEST WISHES!!

Marco

Comments

  • DIM MyArray(1 to maxR,1 to MaxC) As String * 1

    [code]
    ' Read the screen
    For col = 1 to maxC
    For row = 1 to maxR
    ' I'm not sure for the SCREEN function becose there sould
    ' be an other argument but I don't know it
    MyArray(row,col) = SCREEN(row,col)
    Next
    Next
    ' Print the screen
    For col = 1 to maxC
    For row = 1 to maxR
    ' I never used lprint statem so I don't know how it works
    LPrint MyArray(row, col);
    Next
    lprint ""' go to next line
    Next
    [/code]
    In the PRINT statem, when you place ; at the end then it won't go
    to the next line:
    [code]
    PRINT "Hello ";
    PRINT "World";
    PRINT "!!!"
    PRINT "-----------"
    [/code]
    The output will be :
    Hello World!!!
    -----------
    With LPRINT it's the same, it's means when you have two
    strings and want to place them one after the other, place ; at the end of the first one

  • Hi there,

    Thanks for the replies on my earlier question. It helped a lot.
    As you can see below.
    The "XY Coord DIM" workes fine now.

    However!!!!!!! Only with small INDEXES like 30 (=900 char)
    Now I want to print a whole sheet of paper with all the characters
    in the "XY Coord DIM". Thats about 9000 characters.

    BUT when I made DIM textlist(80, 80). (= 6400 char)
    instead of textlist(30, 30) it said "OUT OF RANGE" or
    "OUT OF STRINGSPACE"

    I tried to make subroutines (See code below) but that didn't help.

    I thought.... Quote;"Valid index values range from -32,768 to 32,767."
    SO how can I make the array smaller.!
    I mean what's the problem there anyway!


    :-(

    Marco


    CLS
    ' NOTE: There are ONLY TWO TEXTBLOCKS NR 2, NR 3!!!

    '--------------------DATA-----------------------------------------
    tekst2$ = "Aufwiedersehen" 'Text two
    tekst3$ = "ALOHAAA" 'Text three


    DIM SHARED textlist(1 TO 81, 1 TO 81) AS STRING ' init 2D array textlist


    yy% = 0 ' y variable in "leegtevullen" subroutine
    yyy% = 0 ' y variable in "printlist" subroutine

    xtekst2% = 15 ' starting X coord of text two
    ytekst2% = 2 ' starting Y coord of text two
    kolomlengte2% = 6 ' the width of the text block (>6...= return)

    xtekst3% = 3 ' starting X coord of text three
    ytekst3% = 1 ' starting Y coord of text three
    kolomlengte3% = 5 ' the width of the text block (>5...= return)

    uu% = 0 ' variable used in subroutine "vultext2" for MID$....
    udrie% = 0 ' variable used in subroutine "vultext3" for MID$....

    '---------------------METHODS----------------------------------

    FOR k% = 0 TO 6399 ' Giving all the X,Y coord a "."
    character
    GOSUB leegtevullen
    NEXT k%


    tekst2: 'Locating the X,Y coor of text two +
    FOR x2% = 1 TO 80 ' giving the X,Y the right char of text
    two
    GOSUB vultext2 ' see subroutine "vultext2"
    NEXT x2%


    tekst3: ' Same for text three as text two
    FOR xdrie% = 1 TO 80
    GOSUB vultext3
    NEXT xdrie%


    FOR i% = 1 TO 6399 'Put all the all the values of textlist
    GOSUB printlist ' together and print them in a $
    variable
    NEXT i% ' called "totaaltext$"
    PRINT totaaltext$;
    END
    '----------------------SUBROUTINES-----------------
    leegtevullen:
    yy% = yy%
    xx% = xx% + 1
    m = k% MOD 80
    IF m = 0 THEN
    xx% = 1
    yy% = yy% + 1
    END IF
    '**************HERE IT SAYS "OUT OF**************
    textlist(yy%, xx%) = "." '****** STRINGSPACE"*********

    RETURN

    vultext2:
    teller2% = x2% + (kolomlengte2% - 1)
    B = teller2% MOD kolomlengte2%
    IF B = 0 THEN
    xtekst2new% = xtekst2%
    ytekst2new% = (ytekst2% + (teller2% / kolomlengte2%)) - 1
    ELSE
    xtekst2new% = xtekst2new% + 1
    ytekst2new% = ytekst2new%
    END IF
    uu% = (uu% + 1)
    textlist(ytekst2new%, xtekst2new%) = MID$(tekst2$, uu%, 1)
    RETURN

    vultext3:
    tellerdrie% = xdrie% + (kolomlengte3% - 1)
    bb = tellerdrie% MOD kolomlengte3%
    IF bb = 0 THEN
    xtekst3new% = xtekst3%
    ytekst3new% = (ytekst3% + (tellerdrie% / kolomlengte3%)) - 1
    ELSE
    xtekst3new% = xtekst3new% + 1
    ytekst3new% = ytekst3new%
    END IF
    udrie% = (udrie% + 1)
    textlist(ytekst3new%, xtekst3new%) = MID$(tekst3$, udrie%, 1)
    RETURN

    printlist:
    yyy% = yyy%
    xxx% = xxx% + 1
    n = i% MOD 80
    IF n = 0 THEN
    xxx% = 1
    yyy% = yyy% + 1
    END IF
    totaaltext$ = totaaltext$ + textlist(yyy%, xxx%)
    RETURN


  • OK. I'm not sure if I understand but first of all, you should make sure you are using far strings. Look in the help file under command line options. Anyway, each position is a character right? If so use dim(x as integer, y as integer) os string * 1 instead of just as string.

    --------------------------------------------
    I will bend your mind with my spoon...

  • : OK. I'm not sure if I understand but first of all, you should make sure you are using far strings. Look in the help file under command line options. Anyway, each position is a character right? If so use dim(x as integer, y as integer) os string * 1 instead of just as string.
    :
    : --------------------------------------------
    : I will bend your mind with my spoon...
    :
    Right on!!!! That was the trick.
    It works fine now.

    I believe if you don't use the "* 1" after string, you're making a dynamic Array. Right?

    What are the limits of Static array's and dynamic array's in Qbasic.
    Where do you use dynamic arrays for?

    Marco

  • No, string * 1 defines how many characters long a string should be.

    I don't really know about static/dynamic, but that may well be. Static means it's created at run time and the memory use is set, right? And dynamic means it's made on the fly so the memory use can change?? (don't know if that's right, that's why i'm asking)

    I guess it would make sense that wihout * 1 it's a dynamic array.


    : : OK. I'm not sure if I understand but first of all, you should make sure you are using far strings. Look in the help file under command line options. Anyway, each position is a character right? If so use dim(x as integer, y as integer) os string * 1 instead of just as string.
    : :
    : : --------------------------------------------
    : : I will bend your mind with my spoon...
    : :
    : Right on!!!! That was the trick.
    : It works fine now.
    :
    : I believe if you don't use the "* 1" after string, you're making a dynamic Array. Right?
    :
    : What are the limits of Static array's and dynamic array's in Qbasic.
    : Where do you use dynamic arrays for?
    :
    : Marco
    :
    :

  • What is dynamic array ?
    Dynamic array is an array where you can change the number of element
    example:
    [code]
    REM the next line tell the qb "We will use dynamic arrays"
    REM $dynamic
    ' Declare an array of 1 element
    Dim x(0) As Integer

    input "How many element ? ", a

    ' resize the x array to 'a' elements
    ReDim x(a) As integer
    [/code]

    Most of languages use fixed lenght string (array of char)
    but in basic, when you declare a string of variable length it's like a dynamic array of char
    example :
    [code]
    Dim t1 as String * 8
    Dim t2 as String

    t1 = "1234"
    t2 = "1234"

    Print "pos: 12345678"
    Print "t1= <" + t1 + ">"
    Print "t2= <" + t2 + ">"
    [/code]

    If you have a problem with memory then run qb /ah and declare your array :
    [code]
    Common Shared TextList() As String * 1

    ReDim Shared TextList(80,80) As String * 1
    [/code]



    When you did DIM text(80,80) as string there was an error out of memory becose every variable length string has it's initial size (large)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories