473,548 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(myerrorob ject)
alert(myerrorob ject.filename);
{
my_function('bl a: ',myerrorobject );
}
<---

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

Regards,
Wolfram Heinz

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

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

I get the "myerrorobject. filename" in the alert-Box, but I get an
"undefined"-error, if I try to access myerrorobject.f ilename (or other
properties) in the function "my_functio n".
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(myerrorob ject) {
alert(myerrorob ject.filename);
}
{
my_function('bl a: ', 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
2131
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 have been coding f.close()
8
1432
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 all?
14
336
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*/); } //... //sometimes change m, e.g.:
2
4175
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 then close the window. There was no problem if I just clicked other place on the form. everything was working as charm. However, If I want to...
17
5899
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; n < 100000; n++) mm(); timer2 = time(NULL); exectime = difftime(timer2, timer1);
1
2453
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
4511
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 known at run time. Therefore a lot of template based trick isn't too useful. Considering datafile float x(3) 3.5, 2.5, 8.9 double y(3)...
5
1160
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
2514
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 at just comp.lang.c++. If one of these groups is too inappropriate, just take it off from where you send your replies.) Hi.
0
1398
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 ? 2. How to sort files by filename (and, if possible, folders on top) ? 3. Is this MAILTO hidden tool still useful against the current Spam robots...
0
7518
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5367
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
755
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.