forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Passing a Variant variable,widecharacter to @LIB()

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Wish List
View previous topic :: View next topic  
Author Message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1054
Location: India

PostPosted: Fri Sep 12, 2003 5:54 am    Post subject: Passing a Variant variable,widecharacter to @LIB() Reply with quote

Passing a Variant variable,widecharacter to @LIB()
=================================
Sometime back I encountered a DLL which required Variant type of variable. I tried INT: STR: nothing but it won't work. Is it possible to have this support in future ?
Also how about passing a widecharacter string as a parameter in @LIB() as newer APIs need this and have no ANSI counterpart.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Sep 12, 2003 8:04 am    Post subject: Reply with quote

These are all issues that may be considered when thinking about VDS 6. It might be possible to build a Variant using the @binary() function. I came across a description of the format once. There are several bytes at the beginning of each variable specifying type, length and so on. So it is not an efficient format, and VDS has always tried fo be fast and efficient.
Isn't it possible to use an API call to convert a standard string to wide format?

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1054
Location: India

PostPosted: Fri Sep 12, 2003 8:11 am    Post subject: Reply with quote

jules wrote:
Isn't it possible to use an API call to convert a standard string to wide format?

Yes possible MultiByteToWideChar but mostly the function didn't work then. I will post an example when I come across once again.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Sep 12, 2003 4:07 pm    Post subject: Re: Passing a Variant variable,widecharacter to @LIB() Reply with quote

CodeScript wrote:
Passing a Variant variable,widecharacter to @LIB()
=================================
Sometime back I encountered a DLL which required Variant type of variable. I tried INT: STR: nothing but it won't work. Is it possible to have this support in future ?
Also how about passing a widecharacter string as a parameter in @LIB() as newer APIs need this and have no ANSI counterpart.


CodeScript,
Below is the definition of a VARIANT in LccWin32 you should be able to find the definition in the oaidl.h file for most of the C/C++ compilers.

Code:
struct _VARIANT {
   union {
   struct __tagVARIANT {
   VARTYPE vt;
   WORD wReserved1;
   WORD wReserved2;
   WORD wReserved3;
   union {
   LONG lVal;
   BYTE bVal;
   SHORT iVal;
   FLOAT fltVal;
   DOUBLE dblVal;
   VARIANT_BOOL boolVal;
   _VARIANT_BOOL bool;
   unsigned long long ullVal;
   SCODE scode;
   CY cyVal;
   DATE date;
   BSTR bstrVal;
   IUnknown *punkVal;
   IDispatch *pdispVal;
   SAFEARRAY *parray;
   BYTE *pbVal;
   SHORT *piVal;
   LONG *plVal;
   FLOAT *pfltVal;
   DOUBLE *pdblVal;
   VARIANT_BOOL *pboolVal;
   _VARIANT_BOOL *pbool;
   SCODE *pscode;
   CY *pcyVal;
   DATE *pdate;
   BSTR *pbstrVal;
   IUnknown **ppunkVal;
   IDispatch **ppdispVal;
   SAFEARRAY **pparray;
   VARIANT *pvarVal;
   PVOID byref;
   CHAR cVal;
   USHORT uiVal;
   ULONG ulVal;
   INT intVal;
   UINT uintVal;
   DECIMAL *pdecVal;
   CHAR *pcVal;
   USHORT *puiVal;
   ULONG *pulVal;
   INT *pintVal;
   UINT *puintVal;
   } __VARIANT_NAME_3;
   } __VARIANT_NAME_2;
   DECIMAL decVal;
   } __VARIANT_NAME_1;
};


Notice it is a structure that has a member that is a UNION of different types. A union is like a structure but it is seen as a single variable and takes the size of the largest variable type listed in the union.

Now for question number 2. A WideChar is a character that takes 2 bytes if you are only sending ASCII characters only then the Wide string would be an array of WORD values with the first byte being the ASCII character and the second byte being a NULL character. I don't know what you were trying to do before but MultiByteToWideChar works for me. You know that the info box cannot show the null character so I made this simple script that replaces the null character with it's ASCII value to post it to an edit box to show that these functions do work with VDS 5.

Code:
#-----------------------------------------------------------------------------#
#                                                                             #
# Default script template - to change it edit <vdspath>\default.dsc           #
#                                                                             #
# Author: Johnny Kinsey aka:MindPower                                         #
#                                                                             #
# Copyright:                                                                  #
#                                                                             #
#-----------------------------------------------------------------------------#
LoadLib kernel32.dll
%%CP_ACP = 0

  DIALOG CREATE,New Dialog,-1,0,309,199
REM *** Modified by Dialog Designer on 9/12/2003 - 11:40 ***
  DIALOG ADD,EDIT,EDIT1,45,34,239,38,EDIT1,,MULTI,WRAP,SCROLL
  DIALOG ADD,TEXT,TEXT1,23,53,,,Type some text and click convert.
  DIALOG ADD,BUTTON,BUTTON1,122,114,,,Convert
  DIALOG SHOW
:evloop
  wait event
  goto @event()
goto close
:BUTTON1BUTTON
  %A = @dlgtext(EDIT1)
  If @Equal(@substr(%A,2),0)
    %B = @Fill(@Div(@len(%A),2))
    %%cnt = 1
    repeat
      %D = @Substr(%A,%%cnt)
      if @Equal(%D,0)
        %C = %C@chr(0)
      else
        %C = %C@Substr(%A,%%cnt)
      end
      %%cnt = @succ(%%cnt)
    Until @Equal(%%cnt,@len(%A))
    %R = @lib(kernel32,WideCharToMultiByte,INT:,%%CP_ACP,0,@ADDR("%C"),-1,@Addr("%B"),@Sum(@len(%B),1),NIL:,NIL:)
    DIALOG SET,EDIT1,%B
  Else 
    %B = @Fill(@Prod(@Sum(@len(%A),1),2))
    %R = @lib(kernel32,MultiByteToWideChar,INT:,%%CP_ACP,0,STR:%A,-1,@ADDR("%B"),@Prod(@Sum(@len(%A),1),2))
    %%cnt = 1
    repeat
      %D = @asc(@Substr(%B,%%cnt))
      if @Equal(%D,0)
        %C = %C0
      else
        %C = %C@Substr(%B,%%cnt)
      end
      %%cnt = @succ(%%cnt)
    Until @Equal(%%cnt,@len(%B))
    DIALOG SET,EDIT1,%C
  End
  %C =
  %A =
  %B =
goto evloop
:close
  FreeLib kernel32
Exit

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1054
Location: India

PostPosted: Fri Sep 12, 2003 4:14 pm    Post subject: Reply with quote

Thanx for that Smile I will check it.
_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Sep 12, 2003 4:32 pm    Post subject: Reply with quote

CodeScript,
You can convert the strings with out the use of MultiByteToWideChar function but if your application will be used in languages that need Unicode support it is safer to use the MultiByteToWideChar function...

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group