0

How to pass field name to a function that returns field value?

function getFieldValue() do
  record(tableName,1).'Contact Person'
end

The above function returns the value of the "Contact Person" field. How can I change the function so it will return the value of any field, by passing the field name?

7 replies

null
    • Mconneen
    • 4 yrs ago
    • Reported - view

    @Westy... In the Java (TM) programming language.. we call this "reflection".. in other languages.. "introspection" (etc)..   To the best of my knowledge,  The Ninox scripting language does not offer any such feature.   To accomplish your objective,  it would be a function with an if / else construct.. :( 

    Maybe others have a different approach. 

    • Choices_Software_Dean
    • 4 yrs ago
    • Reported - view

    function getFieldValue(String : text) do

       String := "'" + String + "'";

       let v := record(tableName,1).String

       v
    end

    getFieldValue("Contact Person") now returns the field name instead of the field value. How can I change the function to return the field value? This is my first attempt at writing a Ninox function.

    • Choices_Software_Dean
    • 4 yrs ago
    • Reported - view

    Oops, apparently I posted at the same time you were writing.

    • Choices_Software_Dean
    • 4 yrs ago
    • Reported - view

    As someone new to Ninox this makes me wonder why Ninox does not use pure Javascript. Is the version they use derived from some other version of Javascript? Knowing where their version came from might be helpful in doing Google searches to find sample functions that use their syntax.

    • Sean
    • 4 yrs ago
    • Reported - view

    @Westy, I got really frustrated with some of the language limitations of Ninox a while back and did some research on designing a programming language. That tamped down my frustration a bit. I don't know if they created their own lexer & parser or customized an existing product. Some have suggested, and I have parroted, this is based on Javascript, but as I learn more about Javascript the only similarity is that it is a programming/scripting language. How Ninox handles arrays  compared to how Javascript handles arrays is a very good example of that.

     

    Like @Mconneen said you can use if-then-else or, if you have a lot of fields, use switch-do.

    • Choices_Software_Dean
    • 4 yrs ago
    • Reported - view

    It seems like Ninox was trying to keep things simple by creating their own scripting language and not using Javascript syntax like == and {}. I can understand trying to save users the frustration of mystaking "==" for "=", and "(" for "{". However, that is a slippery slope, because as their scripting lanquage expands it becomes less friendly for Javascript users. The nice thing about pure Javascript is that whenever you have a question you can do a Google search and instantly bring up 3 or more examples. So you get to learn things from multiple perspectives.

    • Nick
    • 4 yrs ago
    • Reported - view

    Ninox people explanation:

     

    "Ninox is a custom user-friendly english-like language to help users digitize their business processes."

     

    https://ninoxdb.de/en/forum/technical-help-5ab8fe445fe2b42b7dd39ee7/what-is-the-language-5bb3daa9a9ece4783d4d6b10

Content aside

  • 4 yrs agoLast active
  • 7Replies
  • 2451Views