Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
nother question <.<
#1
Code:
SUB FetchInput (keyin$)

  SHARED x%, y%, direction%, movedflag%, stillmoving%, lynnframe AS SpriteFrame
  SHARED coinflip%, debugz%, dflag%, roominfo() AS RoomHeader

  roomsizex% = roominfo(currentroom%).dimensions \ 256
  roomsizey% = roominfo(currentroom%).dimensions MOD 256
  
  keyin$ = INKEY$

SHARED doesnt work anymore??



EDIT: ill just have to pass everything won't i <.<
Reply
#2
No, you have to DIM|REDIM|COMMON SHARED them at module level.

The SHARED statement was one of the worst ideas M$ had (IMO), it makes module-level vars that weren't declared as global become global only in some user-defined routines. It may saved some typing in the gw-basic days, when text-editors used to edit one line at time, but now.. it would make code more buggy when you are using external libs with hundred of procs, consts, type's and external vars -- and i didn't want to add yet another ugly hack to the symbol table to handle SHARED at proc level :P.
Reply
#3
okay, thanks=)

i might as well just use this topic for all my questions because i have another one XD

Code:
CASE 1 TO 2, 4 TO 9, 11 TO 13, 15 TO 16, 18 TO 23, 30 TO 34, 44 TO 45

this seems not to wrk...

i put an END right before it, prog runs fine to the end, then i put END right after it and boom, "invalid page fault" :o

EDIT: sidenote... the program worked fine even with that statement, when i removed the SCREEN 13 statement O.O
Reply
#4
Impossible to know without seeing the code -- if you remove SCREEN, then no GFX routine will ever run, they will simply return w/o doing anything.

SELECT is used in the compiler itself a dozen of times, including the TO ranges, it works fine.
Reply
#5
yeah i realized that theres like a million other things in there that wont go smooth from qb to fb

especially the string * 1 as opposed to byte...

am i understanding correctly that you cant ASC(byte) ?? if thats the case how would i find the value of a byte? thanks, sorry for all the noobish questions... there should be FB newbie help =p
Reply
#6
You can use real BYTE variables in FB, no need for the slow string * 1/asc()/chr$() hacks.

DIM myarray(1000) AS BYTE and then GET #1, , myarray() will work in FB too (as in VB).
Reply
#7
yeah but those hacks were how i learned how to manipulate bytes lol =P

so... does that mean.... you can look right at a byte and evaluate it at face value? o.o

like...

dim a as byte

a = 231

? a (prints 231)

if 231 = a then end (program would end)??


EDIT: ...just tested it

holy crap!!!! awesome!!! wicked!!!! lol

i am such a grasshoppa >.<
Reply
#8
ANOTHER question :oops: sorry...



Code:
DECLARE SUB LoadSprite (FileName$, sprite() AS SHORT, spritepal() AS ANY)

TYPE PalType FIELD=1

  r AS UBYTE
  g AS UBYTE
  b AS UBYTE

END TYPE


DIM lynn(0) AS SHORT
DIM grass(0) AS SHORT
DIM Pal(255) AS PalType
DIM SHARED spritex AS USHORT, spritey AS USHORT
DIM SHARED howmuchhere AS UBYTE


LoadSprite "pics/grass.spr", grass(), Pal()


SUB LoadSprite (FileName$, sprite() AS SHORT, spritepal() AS PalType)


  OPEN FileName$ FOR BINARY AS #1

    GET #1, , howmuchhere
    GET #1, , spritex
    GET #1, , spritey

    spritex = spritex \ 8

    arraysize% = ((spritex) * spritey) \ 2 + 2
    REDIM sprite((arraysize% * howmuchhere) - 1)

[...]

and upon compilation...

Quote:D:\Download\FreeBASIC>fbc ll2.bas
ll2.bas(563) : error 4: Duplicated definition, sprite


now, theres lot of code in between, i only chopped what was relevant.

in qb, you could dim an array as 0 indices, pass it to a sub, redim it to the size you needed, and it would automatically be passed back to the module (with the amount of indices you redimmed in the sub). is this not the case in FB?

Edit: tested with AS SHORT in the declaration and in the sub, still didnt work.

Edit2: just figured it out, i wasnt AS SHORT'ing the REDIM in the sub <.< sorry for the double post, im not sure which is worse, double postiing, or spamming the forum <.<;;
Reply
#9
Use the full declaration with REDIM, in QB if you don't do that you get a "AS clause missing", FB will try to guess the type, that will be the last DEF###.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)