* compare a string variable with a string literal @ 1998-10-10 0:00 H�x�d��m� 1998-10-10 0:00 ` Matthew Heaney 1998-10-11 0:00 ` Dale Stanbrough 0 siblings, 2 replies; 3+ messages in thread From: H�x�d��m� @ 1998-10-10 0:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 519 bytes --] How do you compare a string variable with a string literal?? It's not working. Please post and email response if possible. Hexadecimal <hex16@usa.net> -- ---------------------------------------------------- Reach me by ICQ. My ICQ# is 6014042 or, * Page me: http://wwp.mirabilis.com/6014042 or, * Send me E-mail Express directly to my computer screen 6014042@pager.mirabilis.com Download ICQ at http://www.icq.com/ H�x�d��m� <NOSPAMhex16@usa.net> ---------------------------------------------------- ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: compare a string variable with a string literal 1998-10-10 0:00 compare a string variable with a string literal H�x�d��m� @ 1998-10-10 0:00 ` Matthew Heaney 1998-10-11 0:00 ` Dale Stanbrough 1 sibling, 0 replies; 3+ messages in thread From: Matthew Heaney @ 1998-10-10 0:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 410 bytes --] "H�x�d��m�" <NOSPAMhex16@usa.net> writes: > How do you compare a string variable with a string literal?? It's not > working. Please a small code fragment. We can't help you if you don't post code. You compare string objects the same way you comare any other object - using the equality operator "=": procedure Test (S : in out String) is begin if S = "matt" then ... What's the problem? ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: compare a string variable with a string literal 1998-10-10 0:00 compare a string variable with a string literal H�x�d��m� 1998-10-10 0:00 ` Matthew Heaney @ 1998-10-11 0:00 ` Dale Stanbrough 1 sibling, 0 replies; 3+ messages in thread From: Dale Stanbrough @ 1998-10-11 0:00 UTC (permalink / raw) Someone wrote: " How do you compare a string variable with a string literal?? It's not working. Please post and email response if possible." It does work very well. No doubt you are doing... X : string (1..100); Last : Natural; ... Get_Line (X, Last); ... if X = "hello" then... this will of course return false, because a 5 character string cannot equal a 100 character string. Ada strings _do not_ work like C strings - there is no terminating character at the end of the valid input. If you want to store variable length strings then use ada.strings.unbounded... with ada.strings.unbounded; use ada.strings.unbounded; ... X : string (1..100); Last : Natural; Y : unbounded_string; get_line (x, last); y : = to_unbounded_string (X (1..last)); if y = "hello" then this _will_ do what you want it to. Dale ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-10-11 0:00 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1998-10-10 0:00 compare a string variable with a string literal H�x�d��m� 1998-10-10 0:00 ` Matthew Heaney 1998-10-11 0:00 ` Dale Stanbrough
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox