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.

Dark GDK / dbOpenToRead and dbReadString causing problems

Author
Message
tneva82
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 9th May 2008 13:26


That's the code. If my logic isn't completely off this should print out line determined by lineNumber parameter right? Why textLine(which is char* type) doesn't work? Using debug I notice it gets bad pointer instead.

And while I'm at this if I get above working then following code would parse text in format of "xxxx;xxxx;xxxx;xxxx" into separate strings of xxxx right?



Sorry about all these basic questions. I just hate handling files
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 9th May 2008 17:12
I assume that your variable, textLine is declared like this:
char* textLine;
That is only a pointer, there is nowhere to put the text.

That is the first trouble.

Next, the bad pointer part is caused by the fact that the pointer above is uninitialized. To make an initialized pointer:
char* textLine = NULL;

That still won't fix the real trouble, which is fixed like this:
char textLine[256];

Replace your declaration of textLine with that one, and you will have enough buffer for a string that is 255 characters.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 02:36
strtok does pretty much work like you wrote above. once you get the loading figured out, you are real close

tneva82
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 10th May 2008 13:25
Quote: "I assume that your variable, textLine is declared like this:"


Correct. I fixed the declaration and indeed now it works like a charm. Apart from textLine not being printed with dbText function(wonder what's up with that) but what matters is that line is read from the file and parsed into nice array.

Thanks!
tneva82
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 12th May 2008 09:50
Ran(again) into trouble while trying to code scenario parser. Basicly utilising function made earlier I try to read second line and put it into first array(and in this case only array) which is declared as char **returnText and initialised like this:



So far so good. In reading first file it worked like charm(easy to prove as without it working I couldn't turn the ship!) but here something weird happens.



I have debugged problem to be around here. sprintf works, I get the scenarioFile to be what I wish. parseLine function returns and I can see in debugger parsedText[0] contains the ss2.jpg text I'm looking for. Stays there for dbMakeObjectSphere but when I then press F10 in debugger the ss2.jpg dissapears! So later here:



I'm trying to load "" filename which obviously results in very white background.

What could cause that dissapearing variable? If it didn't work so nicely with the other use I would suspect problem at parseLine function but here I'm out of ideas.

Login to post a reply

Server time is: 2024-11-20 09:21:39
Your offset time is: 2024-11-20 09:21:39