Friday, August 26, 2011

Say, you need to return an array of strings from a COM "interop" object implemented on C# to be able then access to its items from a code on VBScript.

The only correct way to do that is make the method to return the VARIANT which is an array of VARIANTs, not strings.
In other words, the return value of the VBScript's VarType() function has to be 0x200C, not 0x2008 ! Only then VBScript will be able to access the array's members.

In the C# terms, you need to make the code look like follows:


public Object f() { // the function returns (VARIANT *)
Object[] a = new Object[3]; // which is an array of VARIANTs
a[0] = "a"; // each of them contains a string
a[1] = "b";
a[2] = "c";
return a;
}

Thursday, August 25, 2011

cmd variables tricks

Get the variable value with replaced part to some new string:
%variable:wildcard_string=new_string%
Get only part of the variable:
%variable:~num_chars_to_skip%
%variable:~num_chars_to_skip,num_chars_to_keep%
%variable:~num_chars_to_skip_from_start, -num_chars_to_skip_from_end%
%variable:~-num_chars_to_skip_from_end,num_chars_to_keep%
%variable:~-num_chars_to_skip_from_end,-num_chars_to_skip_from_end%
other variable substitutions can be found in the command-line reference

Sunday, August 21, 2011

Pulse

In Debian squeeze videos played in the Adobe flash player had no sound.
A solution - activate the virtual "Pulse" audio driver and make it to be the default.
To do that, create file /etc/asound.conf or ~/.asoundrc with the following content:

pcm.pulse {
type pulse
}

ctl.pulse {
type pulse
}