Comming up features

Previous topic - Next topic

bigsofty

Phew, quick try of my own game source produced the following error...

Code (glbasic) Select
FOREACH w IN self.w[]
IF name$=w.text$[WB_NAME_STRING] THEN RETURN i%
INC i%
NEXT


"gui.gbas"(1685) error : GPC0007 wrong argument type on line...
Code (glbasic) Select
FOREACH w IN self.w[]

Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Code (glbasic) Select

TYPE TX
    text$[]
ENDTYPE

TYPE TT
    w[] AS TX

    FUNCTION foo:
FOREACH w IN self.w[]
IF "x"=w.text$[0] THEN RETURN
NEXT
    ENDFUNCTION

ENDTYPE

This works for me, so can you make a short complete example that does not work?

bigsofty

Quote from: Kitty Hello on 2020-Nov-24
Code (glbasic) Select

TYPE TX
    text$[]
ENDTYPE

TYPE TT
    w[] AS TX

    FUNCTION foo:
FOREACH w IN self.w[]
IF "x"=w.text$[0] THEN RETURN
NEXT
    ENDFUNCTION

ENDTYPE

This works for me, so can you make a short complete example that does not work?

I added... "LOCAL i%, w AS TX" to be more like my original source, it now reproduces the error standalone.

Code (glbasic) Select
TYPE TX
    text$[]
ENDTYPE

TYPE TT
    w[] AS TX

    FUNCTION foo:
    LOCAL i%, w AS TX
FOREACH w IN self.w[]
IF "x"=w.text$[0] THEN RETURN
NEXT
    ENDFUNCTION

ENDTYPE



Also, I just pasted this to the end of the file for reference ...

Code (glbasic) Select
FUNCTION GetWidgetID%: name$
IF name$="" THEN RETURN -1
LOCAL i%, w AS TWidget
FOREACH w IN self.w[]
IF name$=w.text$[WB_NAME_STRING] THEN RETURN i%
INC i%
NEXT
RETURN -1
ENDFUNCTION


Highlighted the code and pressed CTRL+K to block remark it and the IDE crashed and exited to desktop. I Think it has something to do with the  final line not having a carriage return. I redid it again but made sure I pressed enter after the last line, then it didn't crash when I remarked it.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Good find on the IDE. The compiler issue is harder. Can you redesign this piece of code, please  =D

bigsofty

Quote from: Kitty Hello on 2020-Nov-26
Good find on the IDE. The compiler issue is harder. Can you redesign this piece of code, please  =D

I could.. but sometimes I reuse a variable within a block of code, so its not always viable to simply remove the declaration. eg. You will notice I've used the variable "m" twice here, on both occasions its a single type that represents a single material, so logically it makes sense. I could code around it with different variable names but isn't this coding around backwards compatibility?

Actually looking at my game code, I do this quite a lot unfortunately.  :'(

Gernot my opinion is this, this is just a "quality of life" improvement, my opinion is not to spend too much time on it if its causing you grief. By this stage I think every one had gotten used to self. anyways!  :good:

Code (glbasic) Select
FUNCTION ReadFile: filename$
LOCAL f%,l$
LOCAL n%,t$[]
LOCAL i%
LOCAL m AS TMaterial
self.Destroy()
self.SetUp()
f%=GENFILE()
OPENFILE(f%, filename$, TRUE)
//DEBUG "Start read TMaterials.ReadFile("+filename$+") file >\n"
REPEAT
READLINE f%, l$
n%=SPLITSTR(l$,t$[]," ")
IF LEN(t$[])=0 THEN CONTINUE
SELECT t$[0]
CASE "newmtl"
DIMPUSH self.m[], m
self.m[-1].name$=t$[1]
CASE "Kd"
self.m[-1].red# = t$[1]; self.m[-1].green# = t$[2]; self.m[-1].blue# = t$[3]
CASE "Tr"
self.m[-1].alpha# = t$[1]
CASE "Ns"
self.m[-1].size# = t$[1]
CASE "#"
DEFAULT
ENDSELECT
UNTIL ENDOFFILE(f%)
FOREACH m IN self.m[]
m.combined% = ASL((m.alpha#)*255,24)+ASL(m.blue#*255,16)+ASL(m.green#*255,8) + m.red#*255
NEXT
//DEBUG "< End read material file\n"
CLOSEFILE f%
ENDFUNCTION
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

bigsofty

I changed the offending code in this routine...
Code (glbasic) Select
FOREACH m IN self.m[]
m.combined% = ASL((m.alpha#)*255,24)+ASL(m.blue#*255,16)+ASL(m.green#*255,8) + m.red#*255
NEXT

to...
Code (glbasic) Select
FOREACH mat IN self.m[]
mat.combined% = ASL((mat.alpha#)*255,24)+ASL(mat.blue#*255,16)+ASL(mat.green#*255,8) + mat.red#*255
NEXT


...but still got eh error "error : GPC0007 wrong argument type" at the FOREACH line, even though I changed "m" to "mat", only within these lines?!?!
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

OK, I'll quite the possibility to drop the "self.". I'm sorry.

bigsofty

No worries Gernot, thanks for giving it a go.  :booze:
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

erico

Yep, thanks for the efforts! Anything you feel could help will always be appreciated.

Schranz0r

The biggest thing for me would be GLOBALS will show up on any gbas-File in the autocompletion.
Thats a "bug" thats drivin me crazy for years now.
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

dreamerman

New improvements in IDE and language features are welcome, also nice to see some fixes for few bugs, yet from what I've checked that bug with loading images from ShoeBox wasn't fixed :/ I hope that this also will come in proper update ;-) I mentioned that bug here
Check my source code editor for GLBasic - link Update: 20.04.2020

Kitty Hello

Get the beta branch. The Shoebox bug is fixed. You need to recreate the SBX files, though.

Qedo

how do you access the debug branch?

dreamerman

Thanks for looking into it but there is still some issue, check my post in that bug topic.
In Logfile update list I saw that HTML5 platform was added, was it updated to latest emscripten or need some old version is still needed or something? As it was already in this topis there were serious issues with previously available version.

Qedo: find GLBasic on Your Steam Library list, right click - Properties - Betas and there select beta builds :-) from what I see standard version also was updated.
Check my source code editor for GLBasic - link Update: 20.04.2020

Qedo

thanks dreamerman you are always kind and helpful  :booze:
Ad maiora