Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Read statement is reading the Data (I think) into the array but array(XXX).name is empty.

Author
Message
Fangs
16
Years of Service
User Offline
Joined: 24th Oct 2008
Location: 40 some miles North of the Emerald Coast
Posted: 30th Aug 2010 20:14
In my text game, I've lost all my NPCs. In game, when an NPC is supposed to appear, I get 'There is a here' and the game continues.

Checking my code against a back-up copy, I can find no difference.
I placed 'print' statements into the 'for/next' loop to print (i) and array(xxx).name(i). 'i' prints out 1 through 10 while array(xxx).name(i) prints nothing.

In the 'encounters' subroutine I have the same print statements. 'i' is randomly generated and array(xxx).name(i) should give me the name of the NPC. I get the number but no name.

HELP!

The Fangman
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th Aug 2010 21:09
It seems to me that your usage of UDT's is not quite right. I can see it being array(i).name, but not array(xxx).name(i). If this is not it, then maybe you could post where you define the UDTs in your code.

So many games to code.......so little time.
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 30th Aug 2010 21:14
LBFN is correct, you cannot use an array inside a typed array.

array(xx).name is ok

array(xx).name(x) is not ok, It's quite annoying but with some lateral thinking can be worked around

Fangs
16
Years of Service
User Offline
Joined: 24th Oct 2008
Location: 40 some miles North of the Emerald Coast
Posted: 31st Aug 2010 01:33
This code works:






This is the calling code (it also works).



I have compared this code with the current build and can see no differences.

The Fangman
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 31st Aug 2010 03:27
Try reading the values into a variable and then setting the value of the NPC_ARRAY. Instead of :


try



I seem to remember that DBP has trouble reading directly into UDT variables.

So many games to code.......so little time.
Fangs
16
Years of Service
User Offline
Joined: 24th Oct 2008
Location: 40 some miles North of the Emerald Coast
Posted: 1st Sep 2010 03:02
O.K. Guy's I found MY screw-up!!!

Actually there were two mistakes :

1 Max_OBJ was set at '45' while there were 36 read statements.
When MAX_OBJ for/next loop read the 36 lines of data, the
next set of data provided the next 9 lines.

2 The next set of data was in the wrong place (above
NPC_ARRAY).

I guess old age is getting to my eyes! I saw that '45' a thousand times and passed right over. After the # change, it was only a few print statements to find the second problem.

Bottom line...everything works correctly.

The Fangman

Login to post a reply

Server time is: 2024-11-24 11:28:04
Your offset time is: 2024-11-24 11:28:04