Jump to content

Photo

Something I didn't know until now. (XB Compiler)


7 replies to this topic

#1 Retrospect OFFLINE  

Retrospect

    Stargunner

  • 1,082 posts
  • Location:Wakefield, England

Posted Fri Oct 5, 2018 1:42 AM

Hi all.  

 

Just writing to let you all know something that most of you might have already have known, which I didn't have a clue about.

 

When writing any program for the XB Compiler (Senior_Falcon's) ... 

 

If you're using an array for a map, say we call it DIM MAP(24,32) so that's the entire screen map ....

And we have enemies that use something like this

 

DIM EX( 8 ),EY( 8 ) .... This is Enemy X position and Enemy Y position for 8 enemies.

 

We then think, or well I thought, that it would be perfectly reasonable to do this:

 

100 TICKER=0

110 TICKER=TICKER+1

120 IF TICKER=8 THEN 100 

130 IF MAP(EX(TICKER),EY(TICKER))=1 THEN BLAH BLAH ....

 

The whole point is, we can't do this, we CAN in XB but the Compiler hates it.  So there's an answer.  We have to use simpler variables within the Array, such as this:

 

Subroutine:
1000 A1=EX(TICKER) :: A2=EY(TICKER) :: RETURN

 

So that we can address it simply like this;

 

130 IF MAP(A1,A2)=1 THEN BLAH BLAH blah ....

 

So if any of you have been pulling your hair out with the compiler it's good to know that it can't handle an Array within an Array. Or at least the one I'm using hates that.  lol.  So there ya go.  :)


Edited by Retrospect, Fri Oct 5, 2018 1:42 AM.


#2 senior_falcon ONLINE  

senior_falcon

    Stargunner

  • 1,245 posts
  • Location:Lansing, NY, USA

Posted Fri Oct 5, 2018 6:06 AM

Nobody likes documentation. Authors hate to write it, and users hate to read it. But if you had read the docs, on page 19 you would have come to this:

 

ARRAY LIMITATION - Important!! The program being compiled cannot use nested arrays.
For example, if you have the two arrays DIM A(10),DIM B(10); you can use Q=A(X+Y-Z) but
you can't nest the arrays like this: Q=A(B(7)). Use of nested arrays will cause the compiled
program to crash!!! For the above example you would have to split up the statement something
like this: X=B(7)::Q=A(X)


#3 OLD CS1 OFFLINE  

OLD CS1

    Technomancer

  • 5,564 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Fri Oct 5, 2018 6:54 AM

No bad feelings here: no body is going to read either retrospect's post or senior_falcon's documentation :D



#4 Retrospect OFFLINE  

Retrospect

    Stargunner

  • Topic Starter
  • 1,082 posts
  • Location:Wakefield, England

Posted Fri Oct 5, 2018 8:27 AM

Senior Falcon is entirely true and accurate with his surmisation of people vs documentation.  I'm one of them.  It took me four attempts to solve a problem where I didn't think there was one.  Then when it hit me, I said to myself "I'm nesting my arrays" ... I didn't even know what nested array was.  

 

It's all good fun though.  I'm on with another little game.  This time you get to shoot things.  



#5 RXB OFFLINE  

RXB

    River Patroller

  • 3,319 posts
  • Location:Vancouver, Washington, USA

Posted Fri Oct 5, 2018 12:25 PM

Yea XB can do this:

 

IF Z(XY(R(M),C(N)))>0 THEN 200

 

The XB ROM does most of this work for finding the ARRAY address while GPL does the parsing of the original statement.

 

6 variables, and pastes them all into a single value.


Edited by RXB, Fri Oct 5, 2018 12:27 PM.


#6 Stuart OFFLINE  

Stuart

    Dragonstomper

  • 792 posts
  • Location:Southampton, UK

Posted Fri Oct 5, 2018 3:35 PM

 

Nobody likes documentation. Authors hate to write it, and users hate to read it.

 

 

Unless of course you're a Technical Writer …  ;-)



#7 senior_falcon ONLINE  

senior_falcon

    Stargunner

  • 1,245 posts
  • Location:Lansing, NY, USA

Posted Sat Oct 6, 2018 7:21 PM

No guarantees, but It looks like I can make a change to the code that fetches the value of an array element so it will allow nested arrays. 



#8 LASooner OFFLINE  

LASooner

    Moonsweeper

  • 297 posts

Posted Fri Oct 12, 2018 7:27 PM

 

Nobody likes documentation. Authors hate to write it, and users hate to read it. But if you had read the docs, on page 19 you would have come to this:

 

ARRAY LIMITATION - Important!! The program being compiled cannot use nested arrays.
For example, if you have the two arrays DIM A(10),DIM B(10); you can use Q=A(X+Y-Z) but
you can't nest the arrays like this: Q=A(B(7)). Use of nested arrays will cause the compiled
program to crash!!! For the above example you would have to split up the statement something
like this: X=B(7)::Q=A(X)

 

 

I read it, it didn't go unnoticed.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users