Author Topic: DIM  (Read 2909 times)

roberto

  • Guest
DIM
« on: 2016-Dec-11 »
Code: (glbasic) [Select]
// Project: PioggiaDiMario
// Start: Monday, December 05, 2016
// IDE Version: 14.001

// FREE-VERSION:
// Need Premium for Features:
// 3D Graphics
// Network Commands
// INLINE C/C+++ code

LOCAL a$
GLOBAL b$, n1, n2, n3, postodata
//GLOBAL barig$, cagliarig$, firenzeg$, genovag$, milanog$, napolig$, palermog$, romag$, torinog$, veneziag$
//DIM   pos[6]
//DIM   riga$[811]
DIM   postodata[9]
postodata[0]=0
postodata[1] = -30
postodata[2] = -29
postodata[3] = 1
postodata[4] = 31
postodata[5] = 30
postodata[6] = 29
postodata[7] = -1
postodata[8] = -31

 n1 = 32
 n2 = 90
 n3 = 3
//La formula per trovare la posizione è n1+n2*x+3(y-z), 32+90*5+3(54-51)=491
//dove x è la parte intera del numero diviso 10,
//y è il numero e z è x per 10 +1

menu (a$)

SHOWSCREEN
MOUSEWAIT

//MENU
FUNCTION menu: a$
PRINT "MENU",110,10
PRINT "1. INSERIMENTO NUMERI USCITI", 10,20
PRINT "2. SCELTA RUOTA DA STAMPARE", 10,30
PRINT "3. STAMPA ELENCO RUOTE GIOCABILI IN ORDINE DA 10 A MENO NUMERI", 10,40
PRINT "4. SELEZIONA RUOTA PER STAMPA NUMERI GIOCABILI", 10,50
PRINT "5. VINCITE O PERDITE COMPLESSIVE PUNTANDO 1 EURO", 10,60
INPUT a$, 10,70
IF a$ = 1 THEN GOSUB ruote
ENDFUNCTION

SUB ruote:
PRINT "1. BARI",10,20; PRINT "2. CAGLIARI",10,30; PRINT "3. FIRENZE",10,40; PRINT "4. GENOVA",10,50; PRINT "5. MILANO",10,60; PRINT "6. NAPOLI",10,70; PRINT "7. PALERMO",10,80; PRINT "8. ROMA",10,90; PRINT "9. TORINO",10,100; PRINT "10. VENEZIA",10,110
INPUT  b$, 10,120
//IF  b$=1 THEN GOSUB bari
ENDSUB



*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.10.037 SN:ea8f9b97 - 2D, WIN32
Wordcount:37 commands
compiling:
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:77: error: no matching function for call to `DIM(DGInt&, int)'
Q:/Compiler/platform/Include/glb.h:916: note: candidates are: void __GLBASIC__::DIM(__GLBASIC__::DGIntArray&, DGNat, DGNat, DGNat, DGNat)
Q:/Compiler/platform/Include/glb.h:917: note:                 void __GLBASIC__::DIM(__GLBASIC__::DGNatArray&, DGNat, DGNat, DGNat, DGNat)
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:81: error: `__GLBASIC__::postodata' cannot be used as a function
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:85: error: `__GLBASIC__::postodata' cannot be used as a function
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:89: error: `__GLBASIC__::postodata' cannot be used as a function
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:93: error: `__GLBASIC__::postodata' cannot be used as a function
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:97: error: `__GLBASIC__::postodata' cannot be used as a function
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:101: error: `__GLBASIC__::postodata' cannot be used as a function
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:105: error: `__GLBASIC__::postodata' cannot be used as a function
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:109: error: `__GLBASIC__::postodata' cannot be used as a function
C:\Users\gabriele\AppData\Local\Temp\glbasic\gpc_temp0.cpp:113: error: `__GLBASIC__::postodata' cannot be used as a function

why? :'( :'(
« Last Edit: 2016-Dec-12 by spacefractal »

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 271
  • to program what I have todo how should I program?
    • View Profile
Re: DIM
« Reply #1 on: 2016-Dec-11 »
GLOBAL b$, n1, n2, n3, postodata[]


Ciao
Qedo

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1792
    • View Profile
    • Homepage
Re: DIM
« Reply #2 on: 2016-Dec-12 »
Hello!

This is due to setting up postodata as a variable. You need to set it up as an array. Yes, the error message could be more helpful :-) I have been banging my head against the wall a number of times because of this little thing until I finaly figured it out.

The line:
GLOBAL b$, n1, n2, n3, postodata

Needs to be changed to:
GLOBAL b$, n1, n2, n3, postodata[]

This prepares GLBasic for treating postodata[] as an array.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5074
  • O Rly?
    • View Profile
Re: DIM
« Reply #3 on: 2016-Dec-12 »
Qedo and Moru got it!
Thats your problem.
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3929
    • View Profile
    • Space Fractal
Re: DIM
« Reply #4 on: 2016-Dec-12 »
This is just a code bug.

But in the end, the glbasic parser should catch this kind of error in runtime in the ide, when a array on a DIM is not found?

Can been quite annoying with this kind of bugs and confucsion.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5074
  • O Rly?
    • View Profile
Re: DIM
« Reply #5 on: 2016-Dec-13 »
the debug says all you need:

no matching function for call to `DIM(DGInt&, int)'

Trying to Dim an Int is a bad idea :D
Should be DGIntArray.
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline UBERmonkeybot

  • Mr. Polyvector
  • ***
  • Posts: 243
    • View Profile
Re: DIM
« Reply #6 on: 2016-Dec-14 »
err that's ok then  ;)