Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

bad argument #1 to 'match' (string expected, got function)


Question

Posted

Hi

 

I periodically get the following error. (Code seemed to have been working fine up to the last stable release)

 

Please login or register to see this code.

 

from the following code (line 618 is the string.match line)

Please login or register to see this code.

A type check shows that target of of type string and v is of type nil

 

I'm thinking it's a quotes issue but can't seem to see where....

 

Any help appreciated 

-AF

 

2 answers to this question

Recommended Posts

  • 0
Posted
53 minutes ago, AutoFrank said:

Hi

 

I periodically get the following error. (Code seemed to have been working fine up to the last stable release)

 

Please login or register to see this code.

 

from the following code (line 618 is the string.match line)

Please login or register to see this code.

A type check shows that target of of type string and v is of type nil

 

I'm thinking it's a quotes issue but can't seem to see where....

 

Any help appreciated 

-AF

 

 

We need more clues.

-Where does 'target' come from? It seems to sometimes be a function and that causes a crash (where do you set target?)

-Is 'notifySvc' always a pure a key/value table? You say that v is nil and that doesn't happen to key/tables. Can happen to sequentially numbered tables that have "holes" in them.... But maybe you were referring to 'string.match(target, v)', as it will return nil when it doesn't match.

(Btw, the idiom is  'if string.match(target, v) then ' because if v is a more complex pattern(regex) the test will not return v and thus not  be true)

 

You could put an assert before the match to see what types you get.

Please login or register to see this code.

 

  • 0
  • Inquirer
  • Posted

    Thanks @jgab

     

    I haven't had time to go back to this yet but thanks for the suggestions

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...