April 24, 2024, 11:03:28 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


A couple of quickies!

Started by srod, July 28, 2007, 04:03:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

srod

July 28, 2007, 04:03:04 AM Last Edit: July 28, 2007, 05:23:15 AM by srod
Hi,

so many questions!  :)

2 questions in fact:

The first; if I declare a subroutine which takes WSTRING parameters; e.g.  Sub MySub(a : WSTRING) etc.
Can I call it like this:  MySub("Test!") ? Will the string literal be automatically converted to unicode or do I have to use MySub(L"Test!") etc?  I guess I should also ask if the same is true if I pass a parameter of type STRING; will it automatically be converted to unicode by EMBasic?

Second question; totally unrelated! If I use EMBasic to create a dll, can I specify an entry point function? This is called whenever processes and threads are initialised etc.

Thanks.

Stephen.


**EDIT: okay, have answered the first question; MySub(L"Test!") is required!  :)

Ionic Wind Support Team

The answer to your second question is no.  There is an entry point that is handled by Emergence startup code which manages allocation and deallocation of resources.  Specifically it creates a local heap used by the DLL and cleans up any dialogs you may have created from within the DLL code.

However there are ways around it.  You could have an Init() function in the DLL and call it yourself before using any of the functions, which is common.

You could also link the object files manually and specify a different entry point when creating the DLL.  You would then need to call _dllmain with the same parameters from your own startup code before doing anything dealing with strings.

Paul.
Ionic Wind Support Team

srod

I reckon the Init() function would be the best bet! Thanks.

I presume that to return a string from a dll function I will have to either fill a buffer supplied by the calling application, or can I return a string declared in the dll but outside of any subroutines, i.e. a source global? I realise that a local variable would not work.