View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0007173 | MMW v4 | Framework: Scripts/Extensions | public | 2011-01-14 14:48 | 2011-02-16 23:33 |
Reporter | zvezdan | Assigned To | |||
Priority | urgent | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 4.0 | ||||
Target Version | 4.0 | Fixed in Version | 4.0 | ||
Summary | 0007173: Error because VarType(SDBSongData.FileLength) = 20 while it should be = 3 as before | ||||
Description | Because of this I am getting VBScript error #458 in some of my scripts: "Variable uses an Automation type not supported in VBScript". By the way, if you take a look at MSDN description of VarType's arguments, you cannot find value = 20 for any variable type: http://msdn.microsoft.com/en-us/library/3kfz157h%28v=vs.85%29.aspx Tested 1342 & 1343 builds. | ||||
Steps To Reproduce | Option Explicit Sub OnStartup() Dim oMenuItem Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0) oMenuItem.Caption = "File size VarType" oMenuItem.UseScript = Script.ScriptPath oMenuItem.OnClickFunc = "FileSizeVarType" Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0) oMenuItem.Caption = "If you want to get error" oMenuItem.UseScript = Script.ScriptPath oMenuItem.OnClickFunc = "VarTypeError" End Sub Sub FileSizeVarType(oItem) If SDB.SelectedSongList.Count Then SDB.MessageBox VarType(SDB.SelectedSongList.Item(0).FileLength), _ mtInformation, Array(mbOk) End If End Sub Sub VarTypeError(oItem) If SDB.SelectedSongList.Count Then SDB.MessageBox SDB.SelectedSongList.Item(0).FileLength & " Bytes", _ mtInformation, Array(mbOk) End If End Sub | ||||
Tags | No tags attached. | ||||
Fixed in build | 1345 | ||||
|
This is caused by 0006277. In order to properly support OLE Automation, we probably should have two properties, one using only 32-bits (and thus OLE compatible) and another for full 64-bits. I'd prefer leaving the old name 'FileLength' as 32-bit and add some 'FileLength64' for other purposes. |
|
Well, if you ask me, this is wrong. Many scripts would get the mentioned error because of your current implementation. However, the suggestion with two properties for the same thing is also wrong. You should keep just one FileLength property and you should use variable types already existing in the VBScript, not to invent some new unsupported which leads to errors. You could use vbCurrency as variable type (8 bytes, –922,337,203,477.5808 to 922,337,203,685,477.5807), vbDecimal (14 bytes, +/-79,228,162,514,264,337,593,543,950,335 with no decimal point) or even vbDouble. I suppose the variable type of some database field doesn't need to be same as the variable type of the corresponding API property and you could do the type conversion on-the-fly. |
|
Changing property type from integer to floating point (or other) is not safe either and could break some other code (be it VBS or anything else). So the suggested solution is on the safe side, without any significant drawback. |
|
Could you give me some example when changing property type from integer to floating point could break some code? Your solution with VarType = 20 for sure breaks code, not because it use different numeric variable type then before, but because it is not supported by Microsoft. Your suggestion for sure would break code if we need to use two properties for same thing instead of one. I bet that your suggestion with two properties would require more updates to the existing scripts, then my suggestion with vbCurrency. |
|
According to this http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.varianttype.aspx it seems that vbLong should be enough (-9,223,372,036,854,775,808 through 9,223,372,036,854,775,807.) But according to this http://delphi.about.com/library/weekly/aa121404b.htm it really seems that there isn't an 8-byte signed integer in OLE automation. Note that this problem also occurs for properties ISDBSongData:TotalSamples ISDBSongData:GaplessBytes ISDBSongData:Bookmark ISDBTreeNodeEvents:FreeSpace ISDBDevice:TotalSpace ISDBDevice:FreeSpace |
|
Problem is that this vbLong is VB.Net only, the scripting types are different (see e.g. http://www.csidata.com/custserv/onlinehelp/vbsdocs/vbs6.htm and http://www.csidata.com/custserv/onlinehelp/vbsdocs/vbs218.htm) I haven't realized that VBS doesn't have any 64-bit integer type, so we have to use something different anyway. So let's try to use that vbCurrency type (it's 64-bit integer with fixed 4 digits reserved for fractional part), I suppose that it won't break anything (or much) in VBS code and in case it does in other languages, it will have to be fixed there. |
|
Yeah, even Visual Basic 6.0 vbLong is 4-bytes only, i.e. between -2147483648 and 2147483647. I tried this part of script as an experiment: Dim i i = 2147483647 MsgBox VarType(i) ' displays 3 = vbLong i = 2147483648 MsgBox VarType(i) ' displays 5 = vbDouble also this: Dim i i = 2147483647 MsgBox CLng(i) ' OK i = 2147483648 MsgBox CCur(i) ' OK MsgBox CLng(i) ' generates error |
|
vbCurrency seems to work fine for this purposes Fixed in build 1345 |
|
Verified 1349 |