0

Insert multiple elements into case of switch

Hi!

I would like to fit more items into a switch case but I can't.

This works:

switch 'Progress Bill' do
case 1:
    'End data' := null
case 2:
    'Total Price' := 0
case 3:
    'End data' := null
default:
    "Error"
end

 

This gives error:

switch 'Progress Bill' do
case 1:
    'End data' := null
case 2:
    'Total Price' := 0;
    'End data' := null
case 3:
    'End data' := null
default:
    "Error"
end

 

This doesn't give an error but it doesn't consider the elements after "and"

switch 'Progress Bill' do
case 1:
    'End data' := null
case 2:
    'Total Price' := 0 and
    'End data' := null
case 3:
    'End data' := null
default:
    "Error"
end

Thanks

5 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    I think this (adding {} ) will work:

    switch 'Progress Bill' do
    case 1:
        'End data' := null
    case 2:
        {'Total Price' := 0;
        'End data' := null}
    case 3:
        'End data' := null
    default:
        "Error"
    end
    
    • Sviluppatore Ninox
    • Fabio
    • 1 yr ago
    • Reported - view

    Switch ... case statement needs round brackets () for multiple instructions.
    Try this:

    switch 'Progress Bill' do
    case 1:
       'End data' := null
    case 2:
       (
          'Total Price' := 0;
          'End data' := null
       )
    case 3:
       'End data' := null
    default:
       "Error"
    end
    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    Thanks Fabio , I knew it was something with brackets... 🤭

      • Sviluppatore Ninox
      • Fabio
      • 1 yr ago
      • Reported - view

      RoSoft_Steven 👍🙂

    • Web_Namer
    • 1 yr ago
    • Reported - view

    thanks Fabio and RoSoft_Steven

    it works with round brackets ()

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 5Replies
  • 222Views
  • 3 Following