Debugging your program with the Remote Development Server (RDS)
Adding a Remote Development Server (RDS)
On the Resource Tab, click on the "Remote Files" tab (the computer with a globe behind it). On the top window of the Resources, it should display "Remote Servers". Right-click your mouse inside this window and a small menu should display showing "Add RDS Server" and "Add FTP Server". Select "Add RDS Server". You should now see a dialog box titled "Configure RDS Server".
In the Description field, type in anything you want to allow you to easily identify the RDS Server (such as "Development"). For the Host Name field, enter in the URL that you use to access the website - do not use "http://" or "https://". The Port field, which defaults to 80, is the webserver port. If you use SSL for your website, enter Port 443 and set the checkbox next to "Use Secure Socket Layer". Next, you may enter in the User Name and Password configured in the Cold Fusion Administrator for the RDS. If you do not enter the information here, you will be prompted for it the first time you access the RDS Server.
Once you are successfully able to browse the remote server via the Remote Files tab, you're ready to configure the Development Mappings.
Configuring the Development Mappings
Click on the Debug menu item and select "Development Mappings". The first time you enter this dialog box, the window with all mapping information should be empty. Select the RDS server you wish to map via the drop-down selection box at the top next to "Cold Fusion Server". If you configured your RDS Server with a description of "Development", then you would select "Development" here. At the bottom of the dialog box, you should see three fields, one each for "Studio Path", "CF Server Path", and "Browser Path". For the Studio Path, enter the physical directory on your computer that you use to edit your templates. This could be "N:\Internet\WWW" or "\\Webserver\Internet\WWW". Now for the CF Server Path. This is the path to the same directory entered for the Studio Path except that it is the physical path on the webserver itself. For example, it could be "D:\Internet\WWW". For the Browser Path, enter in the URL you use in your web browser to view your website. For example, enter "www.mysite.com". Once you have entered in all of the information, click on the Add button and then click on the OK button.
Configuring the Debug Settings
Now, let's tell Studio how to debug the program. Click on the Debug menu item and select "Debug settings". Ensure that the RDS server displayed under option #1 is correct. Next, you'll most likely have to monkey around with the URL in item #2 to correct it to point to the correct page. In every page that I debugged for the first time, there was always something wrong with the URL. However, Studio remembers any modifications you entered and normally will display the correct URL the next time you debug your program.
Now remember that the time you have to execute your program step-by-step is the same amount of time configured for the Timeout on the Cold Fusion Administration page. If it's set to 30 seconds, you only have 30 seconds to run your program step-by-step before you get a timeout error. To get around this, add "RequestTimeout=300" to the URL in the Debug Settings. Don't forget to add any other URL variables your program needs to run (if any). Click the OK button when finished.
Debugging your program
Now that you have all the required configuration information set, let's start to debug your program! But before we start, check to see if you are performing any kind of Login function that will force the user to enter their UserID/Password to view the page. If you do, disable it. Otherwise, you won't be able to execute your code because you'll always be prompted to enter your UserID/Password!
If you do not have the Debug tab on your Quickbar (the same one that has "Common, Fonts, Tables, Frames" and others), right-click your mouse on the Quickbar itself and select "Debug" in the menu that is displayed. Click on the Debug tab. This brings up a whole set of buttons to help you debug your program.
Now in order to display useful information in the Debug window, you need to have a Breakpoint (a stopping point) configured somewhere in your code. The first time around using the Debug feature, go ahead and scroll down to the bottom of your program and click on the gray section to the left of the last line of code. This will cause the line to be highlighted in red and a little stop sign will show up in the gray area you clicked on. On the Debug tab of your Quickbar, click on the VCR Play button (Start/Continue) which will start the execution of your program. This will again display the Remote Development Settings dialog box. Double check the URL and if everything looks okay, click on the OK button. If you don't want this dialog box to be displayed every time you click on the Start button, set the checkbox next to "Don't prompt for these settings at next debug session". If everything was configured correctly, your program will run up to the Breakpoint you configured. At this point, a neat little window will pop up that gives you all kinds of information about the current state of your program such as variables and their values. If you look at the left side of the Status bar at the bottom of the Studio window, you'll notice a set of blue boxes showing up, slowly moving from left to right. This is the timer - you have until the boxes reaches the right side of the status bar to complete your debug session. When they reach the right side, your program will now time out. If you have your Cold Fusion timeout set to 30 seconds, it will take only 30 seconds to reach the right side. This is why it's a good idea to add "RequestTimeout=300" to the URL in the Remote Development Settings dialog box.
If you want to step through your program line by line, set a Breakpoint where you want to start stepping through your code. If you currently have a debug session running, you will have to first click on the VCR Stop button (next to the Play button) to end the current debug session. Now start a new debug session and the program will execute up until it hits your breakpoint and which point it'll stop like it did before. If you look at the Debug Quickbar, there is a button to the right of the Stop button that displays "Step Into" when you hold your mouse stationary over it. Clicking this button will allow you to execute your program one line at a time. Any new variables that are defined will now be shown in the Debug window.
If you click on the little red stop sign of a Breakpoint, it will turn into a white stop sign and the line will be highlighted in a dark gold. This is a disabled Breakpoint. It won't stop your program but it'll allow you to quickly find where it is in your program. Clicking on the Breakpoint a 3rd time will remove it.
The Debug Window
The Debug window is a wonderful thing! By now, I'm sure you're already in love with it. I will go into the different tabs listed at the bottom of the Debug window.
Watches
If you want to view the contents of a variable or watch its current value as you step through your program but don't want to be distracted by seeing all of the defined variables on the Variables tab, this is the tab for you. In the text box, type in the variable name in question. If you want to see it's current value, click on the Evaluate button. However, if you want to see its value as the program runs, click on the Watch button and it'll be added to the Watch List.
Recordsets
This tab will show you all of the query variables defined, the amount of records it returned, and the SQL used to perform the query.
Tag Stack
This tab will show you the current template you are running which is handy if you are stepping through included templates. Additional information is also displayed such as if you are currently inside a CFOUTPUT block.
Output
This tab will show you the currently generated HTML so far.
Breakpoints
All breakpoints defined in your program are displayed here with the template the Breakpoint exists, the line number of the Breakpoint, and the Breakpoint condition. You can activate/deactivate any Breakpoints by double-clicking on it here. If you want to add a condition to a Breakpoint, right-click on the Breakpoint and select "Edit Condition". The condition you enter follows the same syntax you would use in a conditional cfloop. For example, you only want to stop at this particular Breakpoint when the variable "Total" is equal to zero. So, you would enter "total equal 0" as the condition.
Variables
All defined variables in your program are displayed here.