BrokenBasic - is my program too complex for BB3D?

Blitz3D Forums/Blitz3D Programming/BrokenBasic - is my program too complex for BB3D?

Crinkle(Posted 2010) [#1]
Well i have made this program and it's finally pushed BB3D over the top. Check out the link:

http://www.selfign.co.uk/BrokenBasic.zip

It's a zip as it's got other files that it reads.

Basically the program is supposed to read weapons, and then its going into the second part now where it then opens other files and checks their <Name> tags to make sure the strings match what is referenced in weapons. But it doesn't work. the function at issue is check_reference_tags as you can probably see, what should happen is it draws out a list of the dep_exp (explosion references) and as it reads through the file match the names it finds to what is in the database. However it matches nothing even though its programmed correctly.

What is going on!!


Yasha(Posted 2010) [#2]
Your problem is on lines 1042=1045:

...
Linenow$=ReadLine(reffile$)
    numline=numline+1
    tagtxt$=""
    If Mid$(Linenow$,2,6)="<Name>" Then
...


For some reason I can't immediately spot, Linenow is being read without the initial tabs (ReadLine isn't supposed to trim starting whitespace, and doesn't in my projects, so I don't know how you made it do that). This means that the <Name> tag is beginning at the first character and your test starting on character 2 is failing.

EDIT: Whoops, got that diagnosis wrong - the tabs are read, but they don't show up in the debugger panel. However, it's causing the same problem - there are two tabs before <Name> and you're only checking at character 2, so it still won't match. You'll also need to do something about the fact that the tags in the data files don't seem to be consistent as far as capitalisation goes. END EDIT

Now, that said, please lose the arrogance. Your program isn't too complex for Blitz3D, but it is a mess of undeclared or even unused variables, incorrect types, inconsistent and nigh-unreadable indenting and a total misunderstanding of XML (seriously, this whitespace issue is exactly the sort of problem that file format is designed to prevent because it's supposed to allow infinitely-nestable data).

For a start, get a decent editor like IDEal that highlights undeclared and incorrectly-typed variables. Storing file handles in strings can't be doing good things for this program's performance.

And next time, please don't include "even though its programmed correctly". It isn't, and it's hard for the rest of us to provide meaningful help through the blind rage induced by that sort of idiotic comment.

Apologies for my tone. I will try to provide solely constructive criticism from here on out.

Last edited 2010


Crinkle(Posted 2010) [#3]
Ahah i got it working now! What it is is one statement is checking LineNow$ and the one below it, which works right, is reading rline$. This would be when i copied and pasted that part of the code from elsewhere, after coding for so long i must have got blind!

BB3D is restored to good standing again!

Last edited 2010


Yasha(Posted 2010) [#4]
OK, I'll try explaining again.

Therefore it would appear that the programming language has some weird flaw in it.


No. Do not leap to this assumption just because you wrote buggy code. Programming languages are mathematically provable as correct and unless you have good reason to believe Mark is an unusually incompetent language designer, this is a total non-starter.

Now, as for the actual issue:

The issue seems to be that in that functions: <snip> don't ever get the code in the middle of them executed.


As I said above, this is because the Mid() check is failing (I don't know if you read my correction to my initial idea - I changed it after a couple of minutes). The actual tag part of LineNow, "<Name>", begins at character 3 and you're searching for it at character 2, so this always fails.

you must be overreacting, its not terrible and generally i try and make sure things are tab-stopped appropriately


Yes, I was overreacting, but that's what happens when you start by claiming your code is flawless and it's the compiler's fault. I'll be nice if you be nice.

i dont know what you mean by "whitespace issue", i'm just trying to read the XML file!


XML is supposed to be an ultra-portable format that behaves consistently regardless of whitespace (and judging by the actual files, in this case also regardless of capitalisation, although standard XML is case-sensitive). You shouldn't be counting tabs because that's not the way XML is supposed to be parsed: you're supposed to be able to search for them rather than expect them at preset-locations, because if your code has a rigid binary structure (expecting certain data at certain offsets, expecting specific elements on specific line numbers) the XML isn't actually structuring the data, it's just cruft surrounding a structure hardcoded into your program.

I would actually suggest looking for an existing XML parser library and importing that into your project... although you've done a lot of work already. Do consider the option though.


EDIT: rLine$ was one of the unused variables I was talking about. If that was really supposed to be LineNow... you really need to rethink your XML parser design, because as I point out above, you're defeating the whole purpose of XML reading it this way.

Last edited 2010


Crinkle(Posted 2010) [#5]
Well the XML for what purposes i need to use it here it can be a txt file, so though your suggestion may be a wise one, i've come too far down my current path i think! Thankyou for the help anyway


jfk EO-11110(Posted 2010) [#6]
However it matches nothing even though its programmed correctly

Have to say, when you are trying to debug a problem for 200 hours and you still don't see the cause in your code, then most of us would say something like that. Usually in hour 201 it then turns out it was a simple typo somewhere. This, or you'll fix it never and decide to rewrite the whole thing.


puki(Posted 2010) [#7]
Amen to the rewriting something from scratch.


_PJ_(Posted 2010) [#8]

Have to say, when you are trying to debug a problem for 200 hours and you still don't see the cause in your code, then most of us would say something like that. Usually in hour 201 it then turns out it was a simple typo somewhere. This, or you'll fix it never and decide to rewrite the whole thing.


Story of my life