QBasic Stuff/Wish List
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Sep 11, 2000
- 423 views
I finally converted my web page generator and sent it off to Robert. As usual, it took more time to convert than I guessed it would. The code is pretty awful, but there are some goodies I've added in to make it easier to convert from QBasic. [ eof ] I've never gotten used to Euphoria sometimes returning a string, and sometimes returning a numeric code. It's jarring, and the resulting code moves the logic from the top of the 'while' loop and into the loop body: while 1 do o = gets( handle ) if integer(o) then exit end if ... end while I've coded a pair of functions to support the QBasic way of doing things: while not eof( handle ) do s = line_input( handle ) end while eof() is used to check for an end of file. line_input() is guaranteed to return a sequence from the file. If it's the end of the file, it returns an empty sequence. It would be nice (for me, anyway) if Euphoria's built-in file routines worked with eof(). Robert wouldn't need to change their defined behaviors, either - they could still return -1 on EOF. [ string functions ] I've complained a lot about Euphoria choking if a string is sliced wrong, mainly because I'm used to how QBasic handles strings. So I coded the QBasic string routines mid(), left() and right(). They are guaranteed to return a sequence (if only an empty sequence). For example: left("12345",2) --> "12" left("12345",12) -> "12345" left("12345",0) --> "" This makes comparisons with strings safe: -- check for a comment if equal(left(s,2), "--") then (although writing: if left(s,2) = "--" then would be even simpler!) Finally, inspired by Python, left() and right() allow negative indexes. So you can write: -- return string, less 1 character off right side s = left(s,-1) instead of: s = s[1..length(s)-1)] [wishlist] I know that it might be considered bloat, but it would be Real Convenient if Euphoria allowed C++ style comments: // like this in addition to "classic" comments -- like this -- David Cuny