Mar 97 Top 10
Volume Number: 13 (1997)
Issue Number: 3
Column Tag: Symantec Top Ten
Symantec Top 10
By Richard Hill, Symantec Technical Support
This monthly column, written by Symantec's Technical Support Engineers, aims to provide you with technical information based on the use of Symantec products.
Q: My Visual Architect project uses a modal dialog that I want to be able to make appear and disappear without repeatedly allocating and releasing resources. How would I do this?
A: While not immediately obvious, the answer to this is fairly simple. Since CDialog and CDLOGDialog are descendants of CWindow, you can use CWindow's member functions Hide() and Show() to control visibility. To make the dialog go away' without releasing its resources use myDialog->Hide(). Whether it is visible or not, you can update its contents to your liking. Re-display it at the appropriate time with myDialog->Show().
Q: My Symantec C++ Project will not run under the debugger. What might be the problem?
A: There are a couple different reasons for this problem. The most common culprit is corruption in one of your built objects. Choosing Remove Objects from the Build menu is the easiest way to deal with this offender. Another less common (but just as obtrusive) condition has to do with the Project Type setting in the Project | Options submenu. If either Shared or Static Library is selected for the project type, the debugger will be disabled for this project. If the type has been erroneously set to a library, set it back to Application and then Remove Objects from the Build menu. All should be well.
Q: My loop control condition in C is not evaluating correctly. I know x has reached 10, but control is staying in the loop. What's going on?
while (x>10)
{
x = x/y + ...;
}
A: The problem here has to do with rounding and floating point precision. Try this instead:
while (abs(x-10) > 0.0000001)
Obviously, you can change the precision level by changing how many decimal places to use.
Q: My Java applet is accessing an SQL database through dbANYWHERE. The data in my result set is acting weird. Among other things, my comparisons are not evaluating they way I know they should.
A: As it turns out, some SQL databases return their data padded to the length of the field (as defined in the database) plus 1 character (the delimiter). Luckily, Sun included a trim() method in the java.lang.String class. If the database you are connecting to returns padded strings, get in the habit of calling myString = myString.trim().
Q: I want to use a String as my conditional but (myString == the text) is not evaluating true when I know it should.
A: The problem here is that Java defines a String as an object, not a primary data type. You can still do what you want, you just have to use the String member function .equals(). Try this instead: if (myString.equals("the text") {}. This will evaluate to true when it should.
Q: I really love Symantec C++ and think it is the best development environment around, but I have to do some development using libraries that only exist for Metrowerks CodeWarrior . What can I do?
A: Rest at ease. We have developed a translator that allows you to use the MW libraries transparently with your Symantec C++ projects. The translator should be available at our WWW site (ftp.symantec.com) by the time this goes to print.
Q: I have been using Symantec Café (developer release) for some time now. I just upgraded my Mac and now Café will not compile anything. What is going on?
A: If you just copied the Symantec Café folder from one drive to another, rather than reinstalling on the new drive, you may be having a problem with an alias. In the (Translators) folder there is an alias called Java. This alias needs to be pointing to the Java file in your (Java Libraries) folder. If it is not, your project will refuse to compile.
Q: I want to be able to display my source code in an html file, but when I try I lose my formatting, and it makes the code very difficult to read.
A: Try copy and pasting your nicely formatted text from your editor window into a Visual Page window. Now select your code in the Visual Page window and select Preformatted from the Format menu. This method will retain all of your formatting and is the method we use here at Symantec. Another way to accomplish something similar is to drag a source code file to a Visual Page window. However, you may lose some formatting information like fonts and color using this method. It depends on whether your editor saves the formatting information in the file or determines it on the fly'.
Q: How can I change the transparency setting of an image in Visual Page?
A: There are two ways to get to the right place for this. One is to Open the graphic image from the File menu. The quicker method is to hold down the Option key while double clicking on the displayed image. Either way will take you to an editing view for the image. Here you can choose what color (if any) to make transparent. You can define your imagemap regions and links here as well.
Q: I can not get my Java application to access a files that I know are on my drive. What is wrong?
A: Many Macintosh users are in the habit of naming their folders with a suffix of ' (Option-f). Unfortunately, the character set that Java supports for its paths does not include this character (among others). If you are having problems with folder or file access, check to see if any of the folders have any unusual characters and remove them.
Special Thanks to Mark Baldwin, Bob Meyer, Steve Howard, Kevin Kenan, and Steve Wolf.