Jump to content

Nothing (VB/VBScript constant) in AutoIt


DaleHohm
 Share

Recommended Posts

In nearly every case I've encountered, setting a COM object to the null string ("") produces the same result as as setting the same to the constant "Nothing" in VB/VBScript.

This is unfortunately not always true.

So, here is a way to make the Nothing value available in AutoIt:

Local $oVBS = ObjCreate("ScriptControl")
$oVBS.language = "VBScript"
Global Const $Nothing = $oVBS.eval("Nothing")
$oVBS = $Nothing

$Nothing is then available to use anywhere in your script.

Dale

Note: There are cases where nothing works like $Nothing. for others you may be able to use 0, "" or the Default keyword.

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

In nearly every case I've encountered, setting a COM object to the null string ("") produces the same result as as setting the same to the constant "Nothing" in VB/VBScript.

This is unfortunately not always true.

So, here is a way to make the Nothing value available in AutoIt:

Local $oVBS = ObjCreate("ScriptControl")
$oVBS.language = "VBScript"
Global Const $Nothing = $oVBS.eval("Nothing")
$oVBS = $Nothing

$Nothing is then available to use anywhere in your script.

Dale

Thanks Dale. This could come in handy.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

In nearly every case I've encountered, setting a COM object to the null string ("") produces the same result as as setting the same to the constant "Nothing" in VB/VBScript.

This is unfortunately not always true.

So, here is a way to make the Nothing value available in AutoIt:

Local $oVBS = ObjCreate("ScriptControl")
$oVBS.language = "VBScript"
Global Const $Nothing = $oVBS.eval("Nothing")
$oVBS = $Nothing

$Nothing is then available to use anywhere in your script.

Dale

Can you give an example of where "" doesn't work the same as $Nothing?

I don't know anything about VB. Is Nothing a predefined constant in VB?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

One example is the activeconnection property used with some ADO objects. You'll know that "" doesn't work because you'll get an error and $Nothing does because you don't.

Yes, Nothing is a literal constant in VB/VBScript.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

@all

Some of the objects accept the AU3 keyword for this.

Regards

ptrex

And as Dale pointed out in the original post some will accept "". The keyword in both his post and yours is "some".

$Nothing should work in all instances.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 2 years later...

Unfortunately I seem to have found a case where none of the current methods for harnessing the 'Nothing' VB variable work. I'm porting a VB script which does a simple check on backup progress in Symantec Backup Exec System Recovery Manager 8.0.1. The original VB script looks like this:

Option Explicit

Dim oProgDlg

Set oProgDlg = createObject("Symantec.VProProgress.ProgressDlg")
Call oProgDlg.ShowProgress(Nothing,True,True,"")

And my AutoIt version currently like this:

Local $oVBS = ObjCreate("ScriptControl")
$oVBS.language = "VBScript"
Global Const $Nothing = $oVBS.eval("Nothing")
$oVBS = $Nothing

$oProgDlg = ObjCreate("Symantec.VProProgress.ProgressDlg")
$oProgDlg.ShowProgress($Nothing,True,True,"")

But it doesn't work, the Symantec app does nothing at all, no errors are produced either (which is exactly what happens when you replace 'Nothing' in the VB Script with anything else). In the AutoIt version, I've tried 0, "", Default, DIMing a variable with no value and passing that, and the method posted in this thread, nothing works. And when I say nothing works, I mean Nothing doesn't work :graduated:

I'm thinking I will have to just call the poxy VB script externally but that's just dirty, any other suggestions?

Edited by idbirch
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...