Script Debugger 7 0 7 – Applescript Authoring Environment Examples

broken image


Script Debugger 7.0.3 macOS 39.1 MB We too appreciate AppleScript's ability to let you automate repetitive and time consuming tasks. But much like entering a maze at night, using AppleScript requires guesswork — and plenty of feeling around in the dark. Script Debugger 7 offers more options to configure AppleScript applets and drops. Transport safety control applications, have only applets background display and package required libraries directly from the Debugger scripts. We are pleased to announce the release of Script Debugger 7.0.7. Script Debugger 7.0.7 is a free maintenance release. No other scripting tool can match Script Debugger's capabilities for creating, editing and debugging AppleScripts. Its sophisticated Dictionary browser provides far more information than any other tool can and eliminates guesswork and needless experimentation. Simply put, Script Debugger makes AppleScript easy.

We too appreciate AppleScript's ability to let you automate repetitive and time consuming tasks. But much like entering a maze at night, using AppleScript requires guesswork — and plenty of feeling around in the dark. Script Debugger flips on the light switch so you can see what's in front of you. It gives you more than just a flashlight, it gives you daylight.

Explore, Edit, Debug, Deploy | New in Script Debugger 6 | Script Debugger is Great Value | Video Tutorials | Free Trial | Buy Now

What Is Script Debugger?

Script Debugger is an integrated development environment focused entirely on AppleScript. This focus allows Script Debugger to deliver a suite of tools that make AppleScript development amazingly productive. Features like the dictionary explorer allow you to look directly into any application's live scripting interface and step wise debugging with the ability to see the state of all your variables make AppleScript usable in a way you've never experienced before. Of course, this is just a taste of the things Script Debugger does.

Explore, Edit, Debug, Deploy

Explore

Success with AppleScript depends on understanding the applications you want to automate. Script Debugger's dictionary window is where you discover the information and commands applications offer. But that's just the launching off point. The Explorer is the place where you can experiment with the application, where you can explore the data that it offers and manipulate the data to see how the application responds.

The power of Explorers doesn't drop away when you leave the dictionary. As you move to edit your script they follow you and are available as you create and debug your script to show the information you're operating on.

Edit

Once you've discovered how to exploit the capabilities of an application, you're ready to write scripts. Maximize productivity and write scripts easily and quickly with Script Debugger's powerful and flexible code creation features. Insert tell blocks for applications and objects or properties. Script Debugger's ‘clippings' and text substitution features intelligently insert code ranging from AppleScript constructs (such as repeat loops), to basic tell blocks, to application commands (including parameters). Features expressly honed for the peculiarities of the AppleScript language let you easily navigate large scripts, automatically enter 'end' lines and closing delimiters, and more.

Debug

As you create a script, you'll need to test it to make sure it behaves as expected. The first step is to run the script. Should an error stop the script, Script Debugger tracks all the variables and their values up to that point, making it easy to discover what went wrong. Script Debugger presents a complete picture of what's happening as your script runs.

Waves complete 9 6 may 2017 download free. The ever-present Explorers continually appear to show any value in great detail. If the value happens to be a reference to a song in iTunes, for example, it not only gives you its name, it also lets you explore the song's attributes.

Use single-stepping to watch your script as it runs, line by line, viewing the values of all variables at every stage of the script's execution. Use breakpoints to pause your code at key points. You can even create breakpoints that trap conditions in your code. You'll never have to add another AppleScript log statement just to see where you are and what the value of an important variable is. With Script Debugger, your code works by design, not by guesswork.

Deploy

After developing a script, you need to package it for your client, working group, or whoever is going to utilize it. Script Debugger leaps in at this point to check for common errors when packaging scripts. Script Debugger 6's always-on code signing and versioning tools make distributing scripts to others amazingly simple. Should your script contain sensitive or private information, you can export it in Run Only form to prevent others from accessing the code. Script Debugger's unique Manifest tells you instantly what applications, scripting additions, libraries and frameworks are needed in order to run your script successfully

New in Script Debugger 6

Script Debugger 6 delivers 25 new features to make you even more productive, and a raft of other tweaks and improvements. Script Debugger 6 lets you tackle even larger projects, and to take advantage of new features such as progress reporting, script libraries and AppleScriptObjC. View the Script Debugger 6 Release Notes.

Code Folding
Tame long scripts and stay focused on your work

This is our #1 most requested feature! You can now collapse and hide blocks of code and focus on code that matters. This feature makes working on long scripts so much simpler. Even on short scripts, you can hide irrelevant parts of your code to reveal what's important.

AppleScriptObjC Code Completion
Let Script Debugger 6 create AppleScriptObjC code for you

AppleScriptObjC is a powerful technology that makes Apple's developer frameworks available to AppleScript. The problem is that its syntax is both verbose and unforgiving. Script Debugger 6 dramatically improves the AppleScriptObjC coding experience in several ways, starting with code completion tools that generate syntactically correct code.

No more typing current application's NSArray's arrayWithObjects: and hoping you got it right. In Script Debugger 6, class names, methods and enums are all just a click of the escape key away. All the heavy lifting is done for you, down to automatic contextual escaping of terms that clash with AppleScript terminology. Script Debugger 6 even inserts placeholders where you need to enter your own values, so you can simply tab from one to the next. It's a revelation.

AppleScriptObjC Debugging
Script Debugger 6 displays AppleScriptObjC values as you debug

Script Debugger 6 also comes to the rescue when you want to test and debug your AppleScriptObjC code. There's no more dealing with ocid values containing streams of meaningless numbers. With Script Debugger 6, AppleScriptObjC values are fully revealed. When working with NSArrays, NSSets and NSDictionaries, you can explore into them using all of Script Debugger's tools — the guesswork is gone. And like any other code, you can step through line-by-line, inspecting the results as you go. Script Debugger 6 truly opens up the amazing power of AppleScriptObjC.

Always-On Code Signing
Deploy scripts that can pass Mac OS X Gatekeeper

If you distribute scripts, chances are you want them to pass muster with Mac OS X's Gatekeeper, and that means code signing them. Script Debugger 6 makes this task almost invisible with its always-on code signing. Turn it on, and your script is code signed every time it is saved. No more exporting, no more forgetting.

Application, Script Library and Framework Picker
Never type a script library's name again

The power of AppleScript comes from its ability to harness other tools: applications, script libraries and frameworks. Script Debugger 6 introduces popup menus for entering application, library and framework names. You can see at a glance what script libraries are installed where, for example, and you will never need to type — or mis-type — one of their names again. In the case of use statements, it will even enter version numbers where applicable.

Enhanced Clippings

Script Debugger 7 0 7 – Applescript Authoring Environment Examples Pdf

Clippings are now more powerful than ever

New features let clippings — snippets of code you can quickly insert into your code — include the ability to display application/library/framework pickers, and link multiple placeholders so their values change in unison. And they are now fully searchable.

Progress Reporting
Follow along as you debug

AppleScript's progress properties are a great way of displaying a script's progress in an applet, and now you can display them as you run your scripts in Script Debugger 6.

Script Debugger is Great Value

Script Debugger pays for itself many times over. Whether you're a hobbyist, or scripting is part of your job, your time is valuable. Don't waste it. Script Debugger saves you time on a range of fronts: better and faster editing, comprehensive debugging tools that go way beyond simple logging, and a dictionary Explorer that cuts through the tedium of scripting dictionaries to get straight to the point.

The price of Script Debugger 6 has been reduced by 50% making it affordable to anyone interested in make the most out of AppleScript.

Be Ambitious

Script Debugger's code folding, split panes, tabbed windows, code writers and debugging make large projects manageable. With Script Debugger, the simple is easy and the difficult is possible.

Automate More

When you have Script Debugger, you won't shy away from automation opportunities. You'll automate more and reap the benefits. Your projects will let you work more quickly and with greater consistency. Without Script Debugger you may still be doing things manually because creating an automation would not have seemed worthwhile.

AppleScriptObjC Realized

Before Script Debugger 6, working with AppleScriptObjC required specialist software. This powerful technology often requires you to type verbose code, and is unforgiving about case — something foreign to typical scripters. Script Debugger 6's code completion tools do much of the typing for you and address common problems. Debugging AppleScriptObjC is a bear because AppleScript cannot display values you are working with. Script Debugger 6 fixes this by displaying AppleScriptObjC values as you step through your code — there is no more guessing.

-->

This topic describes how to use JavaScript to create scripts that understand debugger objects and extend and customize the capabilities of the debugger.

Overview of JavaScript Debugger Scripting

Script Debugger 7 0 7 – Applescript Authoring Environment Examples Free

Script providers bridge a scripting language to the debugger's internal object model. The JavaScript debugger scripting provider, allows the for use of JavaScript with the debugger.

When a JavaScript is loaded via the .scriptload command, the root code of the script is executed, the names which are present in the script are bridged into the root namespace of the debugger (dx Debugger) and the script stays resident in memory until it is unloaded and all references to its objects are released. The script can provide new functions to the debugger's expression evaluator, modify the object model of the debugger, or can act as a visualizer in much the same way that a NatVis visualizer does.

This topic describes some of what you can do with JavaScript debugger scripting.

These two topics provide additional information about working with JavaScript in the debugger.

JavaScript Scripting Video

Defrag Tools #170 - Andy and Bill demonstrate JavaScript extensibility and scripting abilities in the debugger.

The Debugger JavaScript Provider

The JavaScript provider included with the debugger takes full advantage of the latest ECMAScript6 object and class enhancements. For more information, see ECMAScript 6 — New Features: Overview & Comparison.

JsProvider.dll

JsProvider.dll is the JavaScript provider that is loaded to support JavaScript Debugger Scripting.

Requirements

JavaScript Debugger Scripting is designed to work with all supported versions of Windows.

Loading the JavaScript Scripting Provider

Before using any of the .script commands, a scripting provider needs to be loaded. Use the .scriptproviders command to confirm that the JavaScript provider is loaded.

JavaScript Scripting Meta Commands

The following commands are available to work with JavaScript Debugger Scripting.

Requirements

Before using any of the .script commands, a scripting provider needs to be loaded. Use the .scriptproviders command to confirm that the JavaScript provider is loaded.

.scriptproviders (List Script Providers)

The .scriptproviders command will list all the script languages which are presently understood by the debugger and the extension under which they are registered.

In the example below, the JavaScript and NatVis providers are loaded.

Any file ending in '.NatVis' is understood as a NatVis script and any file ending in '.js' is understood as a JavaScript script. Either type of script can be loaded with the .scriptload command.

For more information, see .scriptproviders (List Script Providers)

.scriptload (Load Script)

The .scriptload command will load a script and execute the root code of a script and the initializeScript function. If there are any errors in the initial load and execution of the script, the errors will be displayed to console. The following command shows the successful load of TestScript.js.

Any object model manipulations made by the script will stay in place until the script is subsequently unloaded or is run again with different content.

For more information, see .scriptload (Load Script)

.scriptrun

The .scriptrun command will load a script, execute the root code of the script, the initializeScript and the invokeScript function. If there are any errors in the initial load and execution of the script, the errors will be displayed to console.

Any debugger object model manipulations made by the script will stay in place until the script is subsequently unloaded or is run again with different content.

For more information, see .scriptrun (Run Script).

.scriptunload (Unload Script)

The .scriptunload command unloads a loaded script and calls the uninitializeScript function. Use the following command syntax to unload a script

For more information, see .scriptunload (Unload Script).

.scriptlist (List Loaded Scripts)

The .scriptlist command will list any scripts which have been loaded via the .scriptload or the .scriptrun command. If the TestScript was successfully loaded using .scriptload, the .scriptlist command would display the name of the loaded script.

For more information, see .scriptlist (List Loaded Scripts).

Get Started with JavaScript Debugger Scripting

HelloWorld Example Script

This section describes how to create and execute a simple JavaScript debugger script that prints out, Hello World.

Use a text editor such as Notepad to create a text file named HelloWorld.js that contains the JavaScript code shown above.

Use the .scriptload command to load and execute the script. Because we used the function name initializeScript, the code in the function is run when the script is loaded.

After the script is loaded the additional functionality is available in the debugger. Use the dx (Display NatVis Expression) command to display Debugger.State.Scripts to see that our script is now resident.

In the next example, we will add and call a named function.

Adding Two Values Example Script

This section describes how to create and execute a simple JavaScript debugger script that adds takes input and adds two numbers.

This simple script provides a single function, addTwoValues.

Use a text editor such as Notepad to create a text file named FirstSampleFunction.js

Use the .scriptload command to load the script.

After the script is loaded the additional functionality is available in the debugger. Use the dx (Display NatVis Expression) command to display Debugger.State.Scripts to see that our script is now resident.

We can select the FirstSampleFunction, to see what functions it provides.

To make the script a bit more convenient to work with, assign a variable in the debugger to hold the contents of the script using the dx command.

Use the dx expression evaluator to call the addTwoValues function.

You can also use the @$scriptContents built in alias to work with the scripts. The @$scriptContents alias merges all of the .Content of all of the scripts that are loaded.

When you are done working with the script use the .scriptunload command to unload the script.

Debugger Command Automation

This section describes how to create and execute a simple JavaScript debugger script that automates the sending of the u (Unassemble) command. The sample also shows how to gather and display command output in a loop.

This script provides a single function, RunCommands().

Use a text editor such as Notepad to create a text file named RunCommands.js

Use the .scriptload command to load the RunCommands script.

After the script is loaded the additional functionality is available in the debugger. Use the dx (Display NatVis Expression) command to display Debugger.State.Scripts.RunCommands to see that our script is now resident.

Use the dx command to call the RunCommands function in the RunCommands script.

Special JavaScript Debugger Functions

There are several special functions in a JavaScript script called by the script provider itself.

initializeScript

When a JavaScript script loads and is executed, it goes through a series of steps before the variables, functions, and other objects in the script affect the object model of the debugger.

  • The script is loaded into memory and parsed.
  • The root code in the script is executed.
  • If the script has a method called initializeScript, that method is called.
  • The return value from initializeScript is used to determine how to automatically modify the object model of the debugger.
  • The names in the script are bridged to the debugger's namespace.

As mentioned, initializeScript will be called immediately after the root code of the script is executed. Its job is to return a JavaScript array of registration objects to the provider indicating how to modify the object model of the debugger.

invokeScript

The invokeScript method is the primary script method and is called when .scriptload and .scriptrun are run.

uninitializeScript

The uninitializeScript method is the behavioral opposite of initializeScript. It is called when a script is unlinked and is getting ready to unload. Its job is to undo any changes to the object model which the script made imperatively during execution and/or to destroy any objects which the script cached.

If a script neither makes imperative manipulations to the object model nor caches results, it does not need to have an uninitializeScript method. Any changes to the object model performed as indicated by the return value of initializeScript are undone automatically by the provider. Such changes do not require an explicit uninitializeScript method.

Summary of Functions Called by Script Commands

This table summarizes which functions are called by the script commands

Command.scriptload.scriptrun (Run Script).scriptunload (Unload Script)
rootyesyes
initializeScriptyesyes
invokeScriptyes
uninitializeScriptyes

Use this sample code to see when each function is called as the script is loaded, executed and unloaded.

Creating a Debugger Visualizer in JavaScript

Custom visualization files allow you to group and organize data in a visualization structure that better reflects the data relationships and content. You can use the JavaScript debugger extensions to write debugger visualizers which act in a way very similar to NatVis. This is accomplished via authoring a JavaScript prototype object (or an ES6 class) which acts as the visualizer for a given data type. For more information about NatVis and the debugger see dx (Display NatVis Expression).

Example class - Simple1DArray

Consider an example of a C++ class which represents a single dimensional array. This class has two members, m_size which is the overall size of the array, and m_pValues which is a pointer to a number of ints in memory equal to the m_size field.

We can use the dx command to look at the default data structure rendering.

JavaScript Visualizer

In order to visualize this type, we need to author a prototype (or ES6) class which has all the fields and properties we want the debugger to show. We also need to have the initializeScript method return an object which tells the JavaScript provider to link our prototype as a visualizer for the given type.

Save the script in a file named arrayVisualizer.js.

Use the .load (Load Extension DLL) command to load the JavaScript provider.

Use .scriptload to load the array visualizer script.

Now, when the dx command is used the script visualizer will display rows of array content.

In addition, this JavaScript visualization provides LINQ functionality, such as Select.

What Affects the Visualization

A prototype or class which is made the visualizer for a native type through a return of a host.typeSignatureRegistration object from initializeScript will have all of the properties and methods within JavaScript added to the native type. In addition, the following semantics apply:

  • Any name which does not start with two underscores (__) will be available in the visualization.

  • Names which are part of standard JavaScript objects or are part of protocols which the JavaScript provider creates will not show up in the visualization.

  • An object can be made iterable via the support of [Symbol.iterator].

  • An object can be made indexable via the support of a custom protocol consisting of several functions: getDimensionality, getValueAt, and optionally setValueAt.

Native and JavaScript Object Bridge

The bridge between JavaScript and the object model of the debugger is two-way. Native objects can be passed into JavaScript and JavaScript objects can be passed into the Debugger's expression evaluator. As an example of this, consider the addition of the following method in our script:

This method can now be utilized in the example LINQ query above. First we load the JavaScript visualization.

Then we can use the multiplyBySeven function inline as shown below.

Conditional Breakpoints with JavaScript

You can use JavaScript to do supplemental processing after a breakpoint is hit. For example, script can be used to examine other run time values and then determine if you want to automatically continue code execution or stop and do additional manual debugging.

For general information on working with breakpoints, see Methods of Controlling Breakpoints.

DebugHandler.js Example Breakpoint Processing Script

This example will evaluate notepad's open and save dialog: notepad!ShowOpenSaveDialog. This script will evaluate the pszCaption variable to determine if the current dialog is an 'Open' dialog or if it is a 'Save As' dialog. If it's an open dialog, code execution will continue. If it's a save as dialog, code execution will stop, and the debugger will break in.

This command sets a breakpoint on notepad!ShowOpenSaveDialog, and will run the script above whenever that breakpoint is hit.

Then when the File > Save option is selected in notepad, the script is run, the g command is not sent, and a break in code execution occurs.

Work With 64-Bit Values in JavaScript Extensions

This section describes how 64-bit values passed into a JavaScript debugger extension behave. This issue arises as JavaScript only has the ability to store numbers using 53-bits.

64-Bit and JavaScript 53-Bit Storage

Ordinal values passed into JavaScript are normally marshaled as JavaScript numbers. The problem with this is that JavaScript numbers are 64-bit double precision floating point values. Any ordinal over 53-bits would lose precision on entry into JavaScript. This presents an issue for 64-bit pointers and other 64-bit ordinal values which may have flags in the highest bytes. In order to deal with this, any 64-bit native value (whether from native code or the data model) which enters JavaScript enters as a library type -- not as a JavaScript number. This library type will round trip back to native code without losing numeric precision.

Auto-Conversion

The library type for 64-bit ordinal values supports the standard JavaScript valueOf conversion. If the object is used in a math operation or other construct which requires value conversion, it will automatically convert to a JavaScript number. Maya 2019 – professional 3d modeling and animation tool. If loss of precision were to occur (the value utilizes more than 53-bits of ordinal precision), the JavaScript provider will throw an exception.

Note that if you use bitwise operators in JavaScript, you are further limited to 32-bits of ordinal precision.

This sample code sums two numbers and will be used to test the conversion of 64 bit values.

Use a text editor such as Notepad to create a text file named PlayWith64BitValues.js

Use the .scriptload command to load the script.

Wirecast pro 12 2 0 download free. To make the script a bit more convenient to work with, assign a variable in the debugger to hold the contents of the script using the dx command.

Use the dx expression evaluator to call the addTwoValues function.

First we will calculate the value of 2^53 =9007199254740992 (Hex 0x20000000000000).

Debugger

First to test, we will use (2^53) - 2 and see that it returns the correct value for the sum.

Then we will calculate (2^53) -1 =9007199254740991. This returns the error indicating that the conversion process will lose precision, so this is the largest value that can be used with the sum method in JavaScript code.

Call a data model method passing 64-bit values. There is no loss of precision here.

Comparison

The 64-bit library type is a JavaScript object and not a value type such as a JavaScript number. This has some implications for comparison operations. Normally, equality () on an object would indicate that operands refer to the same object and not the same value. The JavaScript provider mitigates this by tracking live references to 64-bit values and returning the same 'immutable' object for non-collected 64-bit value. This means that for comparison, the following would occur.

Use a text editor such as Notepad to create a text file named ComparisonWith64BitValues.js

Use the .scriptload command to load the script.

To make the script a bit more convenient to work with, assign a variable in the debugger to hold the contents of the script using the dx command.

First to test, we will use (2^53) - 2 and see that it returns the expected values.

We will also try the number 42 as the first value to validate the comparison operator is working as it should.

Then we will calculate (2^53) -1 =9007199254740991. This value returns the error indicating that the conversion process will lose precision, so this is the largest value that can be used with the comparison operators in JavaScript code.

Maintaining Precision in Operations

In order to allow a debugger extension to maintain precision, a set of math functions are projected on top of the 64-bit library type. If the extension needs (or may possibly) need precision above 53-bits for incoming 64-bit values, the following methods should be utilized instead of relying on standard operators:

Method NameSignatureDescription
asNumber.asNumber()Converts the 64-bit value to a JavaScript number. If loss of precision occurs, **AN EXCEPTION IS THROWN**
convertToNumber.convertToNumber()Converts the 64-bit value to a JavaScript number. If loss of precision occurs, **NO EXCEPTION IS THROWN**
getLowPart.getLowPart()Converts the lower 32-bits of the 64-bit value to a JavaScript number
getHighPart.getHighPart()Converts the high 32-bits of the 64-bit value to a JavaScript number
add.add(value)Adds a value to the 64-bit value and returns the result
subtract.subtract(value)Subtracts a value from the 64-bit value and returns the result
multiply.multiply(value)Multiplies the 64-bit value by the supplied value and returns the result
divide.divide(value)Divides the 64-bit value by the supplied value and returns the result
bitwiseAnd.bitwiseAnd(value)Computes the bitwise and of the 64-bit value with the supplied value and returns the result
bitwiseOr.bitwiseOr(value)Computes the bitwise or of the 64-bit value with the supplied value and returns the result
bitwiseXor.bitwiseXor(value)Computes the bitwise xor of the 64-bit value with the supplied value and returns the result
bitwiseShiftLeft.bitwiseShiftLeft(value)Shifts the 64-bit value left by the given amount and returns the result
bitwiseShiftRight.bitwiseShiftRight(value)Shifts the 64-bit value right by the given amount and returns the result
toString.toString([radix])Converts the 64-bit value to a display string in the default radix (or the optionally supplied radix)

JavaScript Debugging

This section describes how to use the script debugging capabilities of the debugger. The debugger has integrated support for debugging JavaScript scripts using the .scriptdebug (Debug JavaScript) command.

Note

To use JavaScript Debugging with WinDbg Preview, run the debugger as Administrator.

Use this sample code to explore debugging a JavaScript. For this walkthrough, we will name it DebuggableSample.js and save it in the C:MyScripts directory.

Load the sample script.

Start actively debugging the script using the .scriptdebug command.

Once you see the prompt >>> Debug [DebuggableSample Script Debugger 7 0 7 – Applescript Authoring Environment Examples Sentences

Use the sx script debugger command to see the list of events we can trap.

Use the sxe script debugger command to turn on break on entry so that the script will trap into the script debugger as soon as any code within it executes.

Exit the script debugger and we'll make a function call into the script which will trap into the debugger.

At this point, you are back in the normal debugger. Execute the following command to call the script.

Now, you are back in the script debugger and broken in on the first line of the outermost JavaScript function.

In addition to seeing the break into the debugger, you get information on the line (73) and the column (5) where the break tookplace as well as the relevant snippet of source code: var x = 99.

Let's step a few times and get to another place in the script.

Script

First to test, we will use (2^53) - 2 and see that it returns the correct value for the sum.

Then we will calculate (2^53) -1 =9007199254740991. This returns the error indicating that the conversion process will lose precision, so this is the largest value that can be used with the sum method in JavaScript code.

Call a data model method passing 64-bit values. There is no loss of precision here.

Comparison

The 64-bit library type is a JavaScript object and not a value type such as a JavaScript number. This has some implications for comparison operations. Normally, equality () on an object would indicate that operands refer to the same object and not the same value. The JavaScript provider mitigates this by tracking live references to 64-bit values and returning the same 'immutable' object for non-collected 64-bit value. This means that for comparison, the following would occur.

Use a text editor such as Notepad to create a text file named ComparisonWith64BitValues.js

Use the .scriptload command to load the script.

To make the script a bit more convenient to work with, assign a variable in the debugger to hold the contents of the script using the dx command.

First to test, we will use (2^53) - 2 and see that it returns the expected values.

We will also try the number 42 as the first value to validate the comparison operator is working as it should.

Then we will calculate (2^53) -1 =9007199254740991. This value returns the error indicating that the conversion process will lose precision, so this is the largest value that can be used with the comparison operators in JavaScript code.

Maintaining Precision in Operations

In order to allow a debugger extension to maintain precision, a set of math functions are projected on top of the 64-bit library type. If the extension needs (or may possibly) need precision above 53-bits for incoming 64-bit values, the following methods should be utilized instead of relying on standard operators:

Method NameSignatureDescription
asNumber.asNumber()Converts the 64-bit value to a JavaScript number. If loss of precision occurs, **AN EXCEPTION IS THROWN**
convertToNumber.convertToNumber()Converts the 64-bit value to a JavaScript number. If loss of precision occurs, **NO EXCEPTION IS THROWN**
getLowPart.getLowPart()Converts the lower 32-bits of the 64-bit value to a JavaScript number
getHighPart.getHighPart()Converts the high 32-bits of the 64-bit value to a JavaScript number
add.add(value)Adds a value to the 64-bit value and returns the result
subtract.subtract(value)Subtracts a value from the 64-bit value and returns the result
multiply.multiply(value)Multiplies the 64-bit value by the supplied value and returns the result
divide.divide(value)Divides the 64-bit value by the supplied value and returns the result
bitwiseAnd.bitwiseAnd(value)Computes the bitwise and of the 64-bit value with the supplied value and returns the result
bitwiseOr.bitwiseOr(value)Computes the bitwise or of the 64-bit value with the supplied value and returns the result
bitwiseXor.bitwiseXor(value)Computes the bitwise xor of the 64-bit value with the supplied value and returns the result
bitwiseShiftLeft.bitwiseShiftLeft(value)Shifts the 64-bit value left by the given amount and returns the result
bitwiseShiftRight.bitwiseShiftRight(value)Shifts the 64-bit value right by the given amount and returns the result
toString.toString([radix])Converts the 64-bit value to a display string in the default radix (or the optionally supplied radix)

JavaScript Debugging

This section describes how to use the script debugging capabilities of the debugger. The debugger has integrated support for debugging JavaScript scripts using the .scriptdebug (Debug JavaScript) command.

Note

To use JavaScript Debugging with WinDbg Preview, run the debugger as Administrator.

Use this sample code to explore debugging a JavaScript. For this walkthrough, we will name it DebuggableSample.js and save it in the C:MyScripts directory.

Load the sample script.

Start actively debugging the script using the .scriptdebug command.

Once you see the prompt >>> Debug [DebuggableSample Script Debugger 7 0 7 – Applescript Authoring Environment Examples Sentences

Use the sx script debugger command to see the list of events we can trap.

Use the sxe script debugger command to turn on break on entry so that the script will trap into the script debugger as soon as any code within it executes.

Exit the script debugger and we'll make a function call into the script which will trap into the debugger.

At this point, you are back in the normal debugger. Execute the following command to call the script.

Now, you are back in the script debugger and broken in on the first line of the outermost JavaScript function.

In addition to seeing the break into the debugger, you get information on the line (73) and the column (5) where the break tookplace as well as the relevant snippet of source code: var x = 99.

Let's step a few times and get to another place in the script.

At this point, you should be broken into the throwAndCatch method on line 34.

You can verify this by executing a stack trace.

From here, you can investigate the value of variables.

Let's set a breakpoint on the current line of code and see what breakpoints are now set.

From here, we'll disable the entry (en) event using the sxd script debugger command.

And then just go and let the script continue to the end.

Execute the script method again and watch our breakpoint be hit.

Script Debugger 7 0 7 – Applescript Authoring Environment Examples Ppt

Display the call stack.

At this point, we want to stop debugging this script, so we detach from it.

And then type q to quit.

Executing the function again will no longer break into the debugger.

JavaScript in VSCode - Adding IntelliSense

If you would like to work with the debugger data model objects in VSCode, you can use a definition file that is available in the Windows development kits. The IntelliSense definition file provides support for all of the host.* debugger object APIs. If you installed the kit in the default directory on a 64 bit PC, it is located here:

C:Program Files (x86)Windows Kits10Debuggersx64winextJsProvider.d.ts

To use the IntelliSense definition file in VSCode:

  1. Locate the definition file - JSProvider.d.ts

  2. Copy the definition file to same folder as your script.

  3. Add /// to the top of your JavaScript script file.

With that reference in your JavaScript file, VS Code will automatically give you IntelliSense on the host APIs provided by JSProvider in addition to the structures in your script. For example, type 'host.' and you'll see IntelliSense for all the available debugger model APIs.

JavaScript Resources

The following are JavaScript resources that may be useful as you develop JavaScript debugging extensions.

Related topics





broken image