Strings 2000

Discussion in 'Chit Chat' started by Erel, Jan 21, 2015.

  1. Erel

    Erel Administrator Staff Member Licensed User

    What is the output of this code?

    [​IMG]
     
  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Example 1
    Example "2"
    Example 3:
    The "value" of FirstTime is True.
    10 / 3 = 3.33
    Sin (45) = 2.72
    Today is 21/01/2015

    Are you sure this works? It seems like a perl/tcl expression evaluation within strings.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    You are almost correct. I see three mistakes (one is not really related).

    It will in the next version. This is a new string literal that makes it easier to create strings. The three main advantages: multiline, (formatted) string interpolation and no need to escape quotes.
     
    Last edited: Jan 22, 2015
  4. Erel

    Erel Administrator Staff Member Licensed User

    The equivalent code:

    [​IMG]

    There is a missing quote in line 37...
     
    stevel05, wonder and ellpopeb4a like this.
  5. ellpopeb4a

    ellpopeb4a Member Licensed User

    Interesting feature look forward ;)
     
  6. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Insane.
    Now lets see who spots the three mistakes. (I didnt!)
     
  7. MikeH

    MikeH Well-Known Member Licensed User

    Example 1
    Example 2
    Example 3:
    The value of FirstTime is True.
    10 / 3 = 3.33
    Sin (45) = 2.72
    Today is 21/01/2015
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Correct answer:

    Example 1
    Example "2"
    Example 3:
    The "value" of FirstTime is true.
    10 / 3 = 3.3333333333333335
    Sin (45) = 0.71
    Today is 01/22/2015
     
    lemonisdead likes this.
  9. WAZUMBi

    WAZUMBi Well-Known Member Licensed User

  10. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Interesting.
     
  11. sorex

    sorex Expert Licensed User

    @Erel : just wondering...

    what is the point of these $ wrapped around the string in the first line?
    why don't you need double quotes there like we need for normal strings?
     
  12. LucaMs

    LucaMs Expert Licensed User

    Before reading all the posts and especially before answering, I should find out why you do not get compile errors, since I do not know the use of that $ !!!
    Is it B4A???
     
  13. LucaMs

    LucaMs Expert Licensed User

    Read post #3, Luca !!!


    So, we will have a new operator called: "SmartDollar".


    If I wake up, can I (we) suggest other "features" of that operator?
     
    Last edited: Jan 22, 2015
  14. LucaMs

    LucaMs Expert Licensed User

  15. sorex

    sorex Expert Licensed User

    Luca answered my questions indirectly :)
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    And now it is working:

    [​IMG]
     
  17. sorex

    sorex Expert Licensed User

    any chance that this would be the default for all string operations? :)

    PHP also has this variables in strings method ( echo "the time is $now in {$myarray[0]}"; )

    easier (to read) than all the concating
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    This may break existing code. Note that the IDE will autocomplete the closing $" automatically so it is really simple to use the new string literal instead of the standard one.
     
  19. LucaMs

    LucaMs Expert Licensed User

    There is (are) a missing :) underscore, ampersand and CrLf in... many lines! (31-33)
     
  20. Erel

    Erel Administrator Staff Member Licensed User

    Nothing is missing. The new string literal supports multiline strings.
     
    Johan Schoeman and DonManfred like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice