February 2, 1998

Make the Right Comparison

Although Java’s String package is a lot more friendly than C’s string handling, you can still find yourself surprised by its behavior at times. Consider this code: import java.lang.String;public class StringCompareTest { public static void main(String argv[]) { String string1 = “JavaPro”; String string2 = “JavaPro”; if (string1 == string2)

What are we Looking at?

To present your applet in a visually pleasing way, it’s often handy to know the size of the screen that’s available for output. Fortunately, a built-in AWT function makes determining this pretty easy: import java.awt.*;public class ScreenInfo { public static void main(String argv[]) { Toolkit tlk = Toolkit.getDefaultToolkit(); System.out.println(“The current

A const member function

Whenever you define a class member function which does not (and should not) change its object, it’s a good idea to define it as a const member function. There are two advantages to that: One, you guarantee that this member function is safe to use, because it does not change

Activate Your Applets

Did you ever feel the urge to use a nice Java class you just wrote as an ActiveX object on your Windows machine? Good news: you can do it in three easy steps. First, make sure you’ve got the latest build of the Microsoft VM on the target machine (check

Linked List vs. File I/O

Question: Can you explain to me how a linked list works with FILE I/O. For example, how do you add, modify, delete, and search for a student record in a file after you have written a linked list to it using fwrite? Answer: Traditional use of a linked list involves

CL.EXE Error

Question: I installed MS Visual C++ 5.0 at work and on my home machine. At work it’s fine running on Windows NT with 96 megs of RAM. On my home machine – Windows 95 with 24 meg – when I try to compile a small program under the ide I

Variable-length data in structs

Question: Can I have variable length fields in a structure. I have tried something like: typedef struct { int length; char data[length];}; but that won’t compile. Is there a way, or do I just have to use some pointers? Answer: You can declare a structure like this: typedef struct {

Autolaunch library PB configuration

Question: When I open PowerBuilder, I want it to open showing the library painter by default. I tried modifying the Target in the Propeties for the PowerBuilder icon by adding “/p library” to the target. It doesn’t work. I am running PowerBuilder 5.0.3 on Win95. Answer: The following is the

Viewing Text File

Question: How can I view and print a text file in PB5-16? I don’t need to edit. Answer: Use the FileOpen, FileRead and FileClose commands to read you text file. I would suggest reading using LineMode then either concatenating the text into a multiline edit or RTF control. If you

No more posts to show