Recent

Author Topic: Comparing UTF8String to ''  (Read 467 times)

martinrame

  • Full Member
  • ***
  • Posts: 119
Comparing UTF8String to ''
« on: May 31, 2019, 11:05:39 am »
Hi, I need to know if some UTF8Strings are empty, my code is this:

Code: Pascal  [Select][+][-]
  1.       if lJson.Strings['lastname'] = '' or                                                                              
  2.         lJson.Strings['firstname'] = '' or                                                                              
  3.         lJson.Strings['email'] = '' or                                                                                  
  4.         lJson.Strings['telephone'] = '' or                                                                              
  5.         lJson.Strings['message'] = '' then                                                                              
  6.       begin                                                                                                              
  7.         raise exception.create('All fields must be filled.');                              
  8.       end;  

But I get this error:

Code: Pascal  [Select][+][-]
  1. Error: (3284) Operator is not overloaded: "Constant String" or "UTF8String

How can I check if an Utf8String is empty?

martinrame

  • Full Member
  • ***
  • Posts: 119
[Solved] Re: Comparing UTF8String to ''
« Reply #1 on: May 31, 2019, 11:19:55 am »
the solution was enclosing each expression in parenthesis, this way:

Code: Pascal  [Select][+][-]
  1.           if (lJson.Strings['lastname'] = '') or                                                                              
  2.             (lJson.Strings['firstname'] = '') or                                                                              
  3.             (lJson.Strings['email'] = '') or                                                                                  
  4.             (lJson.Strings['telephone'] = '') or                                                                              
  5.             (lJson.Strings['message'] = '') then                                                                              
  6.           begin                                                                                                              
  7.             raise exception.create('All fields must be filled.');                              
  8.           end;  


 

TinyPortal © 2005-2018