Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suggestions on compile??? 2

Status
Not open for further replies.

bakerm

Programmer
Joined
Apr 25, 2000
Messages
53
Location
US
I need to find out how to determine if a compile completed succesfully. I am using a shell function for the compile and it works fine, but I haven't found a good way to determine if the compile was succesfull. I imagine that there must be an API for this.

Thanks, Mark
 
If you are compiling an executable (.exe), then if the compile works, the exe will be written to disk. If the compile does not work, the exe will not be written to disk. This being so, all you have to do is check that the file exists. (and similarly for ocx's, dll's,...).

This can be done with the Dir command:

Dim sTemp As String
sTemp = Dir("full_path_and_name_of_file_being_compiled")

If Len(sTemp & "") = 0 Then

' file does not exist, so compile failed
Else
' file exists, and so compile worked
End If


Simon
 
Simon,

You bring up a good point here that's very subtle. When the DIR function can find the file you requested, the fully qualifed filename will be retured. If it can't find the file an empty string is returned.

The subtle point of this is how you test to see if the Dir function was successful. Typically most books and code that I've seen on the net would do something like this:

If sTemp <> &quot;&quot; Then

In your example you chose to look at the length of the string. This is actually an optimization technique that the NuMega software informs you about during a code review. Checking the Length of the string is actually faster than checking for an empty string and it's a good habit to get into.

Since I saw it here I wanted to make a point of if for the others that might not know about this optimization technique.

I do have a question for you though... If the Dir function returns a String data type and Strings can't be NULL, why did you decide to include the & &quot;&quot; after the variable sTemp in the comparison statement? Snaggs
tribesaddict@swbell.net
 
Just habit. I always do this, as I somtimes do this test on strings that may be Null - but you are correct in your thinking (without saying so) that this is superfluous in this case.

Simon
 
I was going to guess that it was just out of habbit, but I didn't want to put words in your mouth.

Excellent job on responding to the posts here... I really enjoy reading your stuff. Keep up the good work! Snaggs
tribesaddict@swbell.net
 
You may have read before that I do it to learn more myself - and I am not one of these people that like to put themselves in an elevated position and not share code / ideas.

Simon
 
Thanks swilliams this was a very good suggestion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top