Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown Result on any operation #4

Open
Hanqnero opened this issue Mar 22, 2021 · 4 comments
Open

Unknown Result on any operation #4

Hanqnero opened this issue Mar 22, 2021 · 4 comments

Comments

@Hanqnero
Copy link

Hanqnero commented Mar 22, 2021

The Calculator doesn't calculate anything, result always ends with "= ?". If i try to copy the result, it will copy не число (that means Not a Number).

image
image

@Hanqnero
Copy link
Author

Also, in the debug output there's an exception System.Runtime.InteropServices.COMException whenever the mathematical expression changes.

@odinis
Copy link

odinis commented Sep 22, 2021

Having the same issue.

@KarlRamstedt
Copy link

Same issues here. Seems like an external dependency is causing problems.

https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.comexception?view=netframework-4.0

@lrq3000
Copy link

lrq3000 commented Aug 27, 2023

I have been investigating a bit this bug, as I also was interested in making Kalq functional as a more mathematically complete alternative to Launchy's calculator.

I could track down the bug to this line:

interpreter.AddCode(script.Code)

interpreter.AddCode(script.Code)

Where interpreter is:

    ' MS Script Control object, the main engine of kalq
    Private interpreter As New MSScriptControl.ScriptControl

By looking online (it's been decades since I last coded in VB), it seems the issue stems from either a missing, corrupted, misregistered or wrong architecture (project needs to be set in 32-bits mode) msscript.ocx dll. So yes it's difficult to make it work not only in debug, but also in release, because you have to ship the correct dll and it seems it only exists in 32 bits, it's been long deprecated.

So the solution would be to replace this approach with a real math expression evaluator engine, which would also be much safer, as currently Kalq relies on executing any VBscript expression, not just math! So theoretically a nefarious actor could make you execute anything by hijacking your copy/paste (which is possible from websites!).

I had a quick look but it seems math engines are rare for VB, I found this incomplete one but it's much more verbose and complex to use: https://www.jefflewis.net/programming-vb-calculator.html#ModuleMathParser

Given all these limitations and difficulties, I decided to try alternative solutions, and for now I have settled for Qalculate (a much more mature and actively maintained math engine and GUI, much more powerful than Kalq even when it was working), combined with Clavier+ to create a hotkey to mimic how Launchy can be summoned with a simple ALT-LEFT+SPACE hotkey. So far, this approach works wonderfully well, and I get a very powerful math engine, and less memory footprint since it is launched only when I summon it (instead of having a service always running in the background as with Launchy or Kalq), so I likely won't try to fix Kalq as it is a less optimal solution in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants