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.

DLL Talk / dbpro c++ string functions for my dll

Author
Message
chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 27th Dec 2007 23:42 Edited at: 28th Dec 2007 14:32
hi im trying to make a bitmap font plugin

just need to know the c++ equivilents to mid$ and asc

thanks chunks

heres the code..



ive run it through the debugger it crashes on the dbMid(names,b) command im calling these functions from the dbpro dlls if that could cause it ..

the command works in db pro
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th Dec 2007 19:33 Edited at: 28th Dec 2007 19:35
Firstly, the dbMid command takes an extra string as the first parameter (The string that it will be replacing). You can pass NULL if there is nothing to replace.

Secondly, once you receive the string returned by dbMid, you need to free it before the end of your for loop. (You should use CreateDeleteString for this, which can be found in globstruct.h)

Thirdly, if you are going to use the DBP commands, you need to make sure that the required dlls are included in the .exe. In your example, you haven't used any string commands in your test program, and so the string .dll was never included. Put 'temp$ = mid$("",1)' at the bottom of your test program, and run it again. The same applies to 'dbPasteImage'

Fourthly, you never increase the variable 'b' in your loop, causing an infinite loop!

That way is very inefficient anyway, here is a much better and easier way:


This works, because LPSTR is just another way of saying char* (a pointer to a char, or an array of chars). A char contains the ascii value for the letter it represents, so there is no need to use dbAsc. Increasing the value of 'b' (b++) is another way of advancing to the next character in the string. All DBP strings end with a NULL, so we know where the end of the string is. The condition in the for loop ('*b') checks if the character pointed to by 'b' is not NULL. (If it's not NULL, then it's not the end of the string yet). Also, I added an if statement to make sure that 'names' is not a NULL pointer. If it was, it would have caused your example to crash with a fatal exception.

chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 28th Dec 2007 20:01
cheers mate im new to this gonna try it now..
just getting to grips with c++.

i like it though
Its been driving me mad cause the same code works in dbpro


do you mean putting a dummy command in your dbpro code Put 'temp$ = mid$("",1)


I was puzzled why the paste image wouldnt work, it worked when added the color backdrop 0 command .. guess that adds the dll

thanx again
chunks ..
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 29th Dec 2007 12:11
chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 29th Dec 2007 14:25 Edited at: 29th Dec 2007 14:29
Its working quite well i think. I`ve posted it in the 2d forums ..

we`ll see what results we get with it..

Thanks for your help

chunks..
heres the link http://forum.thegamecreators.com/?m=forum_view&t=120799&b=4

Login to post a reply

Server time is: 2024-05-03 19:26:20
Your offset time is: 2024-05-03 19:26:20