Page 1 of 1

Posted: Tue Mar 04, 2003 4:33 pm
by BackupUser
Restored from previous forum. Originally posted by SimpleMind.

Hi,

For now let me tell you the context of my problem. I have a program X that uses plugin modules. These are normal "dll" files but renamed to i.e. "pmx" and are usually made in MS-C/C++ :). If this "pmx" is present in the source directory were X resides, it is recognized and tagable in a plugin list inside the program. I'm trying to translate this C-code to PB. It's just a large Jig Zaw puzzle. Piece by piece gathering the information for the translation.
Now I'm finding some string table constants on my way in the c-code. I have a description from Jacob Navia's manual of LCC to give you some background information.

------------ String tables start ---
This utility allows you to edit the string tables contained in your resource file. String tables are a resource kind for storing character strings in the resource section of the executable instead of using string literal in the program text itself.
The original motivation for this was the ever-growing need under windows 3.0 to have more memory with the space severely limited to 64K for the stack, all character strings, and all static data. This lead to trying to make more space in the data segment by putting the strings somewhere else, and loading /unloading them as needed.
But there are many other beneficial side effects, so the usage of string tables has stayed with us even in windows 98. One of the good side effects is the separation from message text from the code itself, so that if you need to translate the program into another language you do not need to edit the source files, but just the resource file, what is far easier for the person who is doing the translation, since he/she doesn’t have to be a programmer AND a foreign language expert, a rare combination.

------------ string table end ----------

Here are now my questions:

1. Does someone know how to mimic these string table in PB.

2. If this is done by the "Data" statement how can you give the string an ID. Because the program expects from a certain ID number a string with a specific formatting.


SimpleMind,

Perfection is reached not when there is no longer anything to add,
but when there is no longer anything to take away. (A. Saint-Exupery)

- Registered PureBasic Coder. -

Posted: Tue Mar 04, 2003 7:33 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

AFAIK, at this moment, you can't add string-table resources to your apps with PB. If you could, you would use LoadString_() (info in WIN32.HLP). If the string-tables are in the C/C++ DLLs, you can load these strings with LoadString_(). Try and tell us:

Code: Select all

BufferSize = 256 ; expected string length
Buffer = AllocateMemory(0, BufferSize)
If LoadString_(GetModuleHandle_(DLLName$), Constant, Buffer, BufferSize)
  String$ = PeekS(Buffer)
  FreeMemory(0)
Else
  ; resource not found, call GetLastError_()
EndIf
El_Choni

Posted: Tue Mar 04, 2003 8:24 pm
by BackupUser
Restored from previous forum. Originally posted by SimpleMind.

Hi,

El_Choni, thanks for the pre-code. I changed it a little and now I can load the dll and find at the expected ID the string value. So, yes it is possible. Make a loop at the StringID and and all the string constants are listed. But as you said that at this moment it is impossible to add string-table resources to PB apps. In that case I have to stop with this transalation of C-code. I can't change the way the application is calling and using the dll's I just want to build with PB.

BufferSize = 256 ; expected string length
Buffer = AllocateMemory(0, BufferSize)
DLLName$ = OpenFileRequester("","","DLL's (*.dll)|*.*", 0)
#StringID = 101

If OpenLibrary(0, DLLName$)
If DLLName$
If LoadString_(GetModuleHandle_(DLLName$), #StringID, Buffer, BufferSize)
String$ = PeekS(Buffer)
FreeMemory(0)
MessageRequester("String table item",String$,0)
Else
MessageRequester("Error", "Can't load the module or bad module format.", 0)
EndIf
EndIf
EndIf; OpenLibrary()

Thanks anyway, you've saved a lot of time for me.

SimpleMind,

Perfection is reached not when there is no longer anything to add,
but when there is no longer anything to take away. (A. Saint-Exupery)

- Registered PureBasic Coder. -

Posted: Thu Aug 21, 2003 1:28 am
by waffle
could this be done by:

1 - make a resource file using Resource Workshop (Borland C++ kit)
2 - use the Includebinary "aresource.res"

would this work?
I can't test it as i unistalled all my c++ stuff years ago.

i was scanning the API today and found some more stuff...
there is a way...

see here:
http://msdn.microsoft.com/library/defau ... ources.asp

basically, have your main app/dll capable of functioning without resources.
next, create your own resource editor or use a Resource Compiler.
Then, you can use the api to start another program to add the resources to your completed app. So, its posible, but could be beyond most basic users and would not be compatible with linix or amiga OS.

Posted: Mon Jan 10, 2005 1:16 pm
by freddix
I wil try this later in the day ;)

Thanks :)