473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How can I avoid type-conversion (object variable to string)

Hi there,
How can I avoid type-conversion (object variable --> string) when
passing an object variable to a function?

Example:
-->
catch(myerrorobject)
alert(myerrorobject.filename);
{
my_function('bla: ',myerrorobject);
}
<---

I get the "myerrorobject.filename" in the alert-Box, but I get an
"undefined"-error, if I try to access myerrorobject.filename (or other
properties) in the function "my_function".
Why?

Regards,
Wolfram Heinz

Jul 23 '05 #1
1 1400
Wolfram Heinz wrote:

[snip]
-->
catch(myerrorobject)
alert(myerrorobject.filename);
{
my_function('bla: ',myerrorobject);
}
<---

I get the "myerrorobject.filename" in the alert-Box, but I get an
"undefined"-error, if I try to access myerrorobject.filename (or other
properties) in the function "my_function".
Why?


If that's your literal code, it's because myerrorobject doesn't exist
when the function call occurs. The code will be parsed as:

catch(myerrorobject) {
alert(myerrorobject.filename);
}
{
my_function('bla: ', myerrorobject);
}

Notice that there are two blocks. The catch identifier will only exist
in the first.

To be honest, I'm surprised that would work at all. A catch clause
must be followed by a block unlike if, for example, which may be
followed by either a statement or a block.

If what you posted is a typo, I think you'll have to post a more
complete example.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stephen Ferg | last post by:
I've just spent several very frustrating hours tracking down a bug in one of my programs. The problem was that I was writing text to a file, and when I was done I coded f.close when I should...
8
by: Martin Gieseking | last post by:
Hello I've the following piece of code that compiles fine: typedef int (*(*T)); T *t = new T; Now I would like to avoid the typedef but don't really know how to do this. Is it possible at...
14
by: Alexander Malkis | last post by:
A real-life example: int alpha_beta(unsigned depth,Position p, Move& m /*,other args*/) { //...do smth with p if(depth) { Move m; int val=alpha_beta(depth-1,p,m /*,other args*/); } //......
2
by: cschang | last post by:
I have a form containing a link next to an input box. I include a javascript function in the input by using the onblur='fuc()'. I used this function to open another ASP page to do something and...
17
by: Pushkar Pradhan | last post by:
I want to time my matrix multiply code (in MFLOPS). I want to run the code 100,000 times or some other big number. This can be done 2 ways (for and while loops): timer1 = time(NULL); for(n = 0;...
1
by: Scott Yost | last post by:
I have a managed class A which I import via a DLL. public __gc class A { public B otherClass; } And another class C which is just in a CPP file - not in the DLL. #include <b.h> class C
13
by: Fei Liu | last post by:
Hi Group, I've got a problem I couldn't find a good solution. I am working with scientific data files in netCDF format. One of the properties of netCDF data is that the actual type of data is only...
5
by: hg | last post by:
Hi, In C/C++ I got used to write an expression like so: #define TEST 0 if (TEST == value) { }
16
by: mike3 | last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms- windows.programmer.win32 since there's Windows material in here as well as questions related to standard C++. Not sure how that'd go over...
0
by: samz | last post by:
Hello, Here is a simple PHP recursive file list (with interactive and visual FX) Sam's Files http://acc.jexiste.ch/JPN/RecurciveDIR12.RAR 1. How to ignore/avoid empty folders in this PHP script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.