Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Getting undefined when calling more than one function #31

Closed
kinju4374 opened this issue Jul 25, 2016 · 16 comments
Closed

Getting undefined when calling more than one function #31

kinju4374 opened this issue Jul 25, 2016 · 16 comments

Comments

@kinju4374
Copy link

I am trying to use the following javascript and I am getting an undefined error. Can you please suggest what am I doing wrong.

function a(){ return 10; }; function b(){ return 20; }; function c(){ return 30; }; function abc(){ return a()*b()*c(); }

@obastemur
Copy link
Contributor

Using ChakraCore ch from command line, I haven't get any error;

function a(){
return 10;
};
function b(){
return 20;
};
function c(){
return 30;
};
function abc(){
return a()*b()*c();
}

print(abc())

@kinju4374
Copy link
Author

When I am using print, I am getting, print is undefined. But when I add z=abc() then execute, it gives me 6000 which is correct output.

@obastemur
Copy link
Contributor

Indeed print is defined by ch host. My guess is you use this script from your app that embeds ChakraCore?

In that case, you don't need z just abc() to the end should be enough.

@kinju4374
Copy link
Author

Yes, just abc() is also working.

I am just trying the ChakraHost Samples and trying different javascript in that.

@obastemur
Copy link
Contributor

In that case; there is no issue here. If you want a particular script execution to return something, you may add that to the end.

closing this one. @kinju4374 Thanks for asking.

@kinju4374
Copy link
Author

Thanks for the help. I also have a query, when I use Debug.WriteLine() to check result of the javascript in c#, it doesn't display anything but when I use same in your sample, it gets displayed on TextBlock.

Can you please suggest how to debug javascript code when ChakraHost is used?

@liminzhu
Copy link
Member

Here's a relevant thread for you @kinju4374 chakra-core/ChakraCore#1274.

@kinju4374
Copy link
Author

@liminzhu thanks. This works fine for me. I have one more doubt that it will work in Release/ARM version(which we upload on store) without any issues right?

@liminzhu
Copy link
Member

@kinju4374 no problem. Debugging should work on Release/ARM. I don't personally own an ARM device, but you can try it out.

@kinju4374
Copy link
Author

@liminzhu Yes, I will try. It works when Application Process is set as "Script", but I am asking that when I make app Live on the store, it will work without any problems right? When I change debug to Managed only, then the app starts giving Exception.

@liminzhu
Copy link
Member

liminzhu commented Aug 5, 2016

When I change debug to Managed only, then the app starts giving Exception.

@kinju4374 can you clarify that? What exceptions are you getting?

@kinju4374
Copy link
Author

kinju4374 commented Aug 11, 2016

@liminzhu I am getting Exception thrown: 'System.Exception' in ChakraBridge.winmd Exception thrown: 'System.Exception' in mscorlib.ni.dll

It is showing same with Release - ARM version which we used to deploy on store. Please suggest.

@kinju4374
Copy link
Author

kinju4374 commented Aug 16, 2016

@liminzhu @obastemur Do we have Nuget Package for this? I have added reference ChakraBridge.winmd from dist folder in my app. Please help me as I need this to load javascript in my c# project.

Exact Exception is Exception thrown: 'System.Exception' in ChakraBridge.winmd
failed to start debugging.

@liminzhu
Copy link
Member

ChakraBridge.winmd

Are you referring to this project? This sounds like an implementation issue specific to that project, rather than a Chakra/ChakraCore issue. I'd advise opening an issue on that project.

@kinju4374
Copy link
Author

I added this as reference to use ChakraHost API in my project but it gives exception when debug mode is changed

@liminzhu
Copy link
Member

liminzhu commented Sep 8, 2016

Close as the same issue is tracked at deltakosh/JsBridge#15.

@liminzhu liminzhu closed this as completed Sep 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants