What does this* error mean?


#1

*Uncaught TypeError: strMid.substr is not a function.
line 13 column 91

Being generated in the following test program. If I remove the “mid” statement, there is no error. It looks like “m” is coming in as NOT a string??? If not a string, how do I convert “m” from whatever it is to a string?

Test_Hamburger.nsx (29.9 KB)

Windows 10, Chrome, AppStudio vs 6272…


#2

To figure out more, open the Chrome Debugger window. It will where the error is coming from.

Also useful is the console.log statement - you can use that to look at the value of n which you are passing into FuHamburger.

http://wiki.nsbasic.com/Console.log

You might also have a look at the docs for Hamburger to check if you are doing things propertly:

http://wiki.nsbasic.com/Hamburger_(Bootstrap)


#3

Try this:

'MsgBox(m)
If typeof(m) == “object” Then return
FuHamburger(m)

But don’t write Return (don’t know why).


#4

When I first used If typeof(m) == "object" Then Return I got an error message saying the “Return” was not defined… but when I used “return” (NOT capitalized), it worked correctly… thank you for that, the wiki documentation example needs to be changed.

And when I ran it (same program as uploaded on here) but with the code you suggested… clicking on hamburger #1 opened the hamburger and clicking on an entry (#3) jumped to that entry… Oh Joy!

But a second click on an entry (#2) from Form3 resulted in the same error that I first identified at the start of this thread.

I’ll now attempt what George suggested.

Thanks again


#5

Docs fixed - darn autocorrect!


#6

Thanks for Documentation update… helps :slight_smile:

When I ran with console.log… the log showed:

hfunc.js:13 Uncaught TypeError: strMid.substr is not a function
    at Mid (hfunc.js:13)
    at FuHamburger (code.js:10)
    at HTMLDivElement.Hamburger3.onclick (code.js:24)
Mid @ hfunc.js:13
FuHamburger @ code.js:10
Hamburger3.onclick @ code.js:24

I have no idea what this means nor what to do about it.
I’ve reloaded the test program…
Test_Hamburger.nsx (30.0 KB)


#7

One other point… When the program initiates with Form 1, it works correctly when:

  • click on Hamburger 1 and
  • click on item 2 and/or item 3 >> a jump to Form 2 or Form 11 (as it should)
  • but a click on the Hamburger in that new form results in the error.

However, when program initiates with Form 3 or Form 11 (as the uploaded program does), a click on the Hamburger IMMEDIATELY results in the error.


#8

Found it… Must have the ‘If typeof(m) == "object" Then return’ code immediately after the opening of the Hamburger… I hadn’t put it on Form2 nor Form11


#9

Yes, that is vital. The click gets two events - this is to make sure you handle the one you really want.