Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Multiple Statements On 1 Line

  1. #11
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732
    Hi John,

    you can do the following currently already (with same result):
    Dim myString As String = """This
    is
    ""quoted""
    Text"""     
    
    MsgBox 0, myString
    
    to produce:
    "This
    is
    "quoted"
    Text"

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #12
    Member
    Join Date
    Jul 2010
    Location
    Phoenix, Arizona, usa
    Age
    74
    Posts
    54
    Rep Power
    19

    Question Problem with Multiple Statement on same line with : and Return

    I am having a problem with a return statement on the same line as previous program statement. For example the following script does not work:

     
    ' tryreturn.bas April 25, 2011
    uses "console","os","file","dt"
    dim utmp as string
    setutxtmp("c:\thinbasic\utx2.tmp")
    utmp=getutxtmp()
    console_write "UTXTMP=" & utmp & $CRLF
    console_waitkey
    '==================== end of thinbasic script =================
    function setutxtmp(text2 as string) as string
    static utxtmp as string = "utx.tmp"
    if(len(text2)>0) then : utxtmp=text2 : end if : return utxtmp 
    end function
    function getutxtmp() as string
    dim utxtmp as string : utxtmp=setutxtmp("") : return utxtmp 
    end function
    '==============================================================
    
    HOWEVER IF I MOVE THE FIRST RETURN UTXTMP (IN RED) TO THE NEXT LINE IT WORKS.
    IS THIS A BUG?

    ' tryreturn.bas April 25, 2011
    uses "console","os","file","dt"
    dim utmp as string
    setutxtmp("c:\thinbasic\utx2.tmp")
    utmp=getutxtmp()
    console_write "UTXTMP=" & utmp & $CRLF
    console_waitkey
    '==================== end of thinbasic script =================
    function setutxtmp(text2 as string) as string
    static utxtmp as string = "utx.tmp"
    if(len(text2)>0) then : utxtmp=text2 : end if 
    return utxtmp 
    end function
    function getutxtmp() as string
    dim utxtmp as string : utxtmp=setutxtmp("") : return utxtmp 
    end function
    '==============================================================
    
    NOTE: In these functions I am trying to use static variables in functions to avoid global variables. It is also to make my thinbasic user library as close to my perl and
    c language libraries for my test software applications.

    Also if I cannot trust the use of : to separate program statements this can be
    a problem for the users of my application(s) as users will also have to write thinbasic scripts patterned after the examples I will be providing.

    If we can fix this bug it would help a great deal. Also it would make thinbasic more robust in the use of : to separate program lines.


    Last edited by ErosOlmi; 26-04-2011 at 09:27.

  3. #13
    Member
    Join Date
    Jul 2010
    Location
    Phoenix, Arizona, usa
    Age
    74
    Posts
    54
    Rep Power
    19

    Can Someone Confirm This Bug

    Can someone confirm this bug?

    Since I am using MS-Wordpad as my text editor
    perhaps the carriage return or line feed characters
    are causing problems.

    Thanks.

  4. #14
    hi john,
    i think there is no bug , it returns what is in utxtmp.
    may be it is when you copy code from word to thinbasic ide.
    also when the readers of your code tried to copy it to thinbasic ide there is all sorts of errors in copying so if you have used the code tag "#" when posting code it will be formatted with color in the forum page, and can be copied correctly to the ide.
    regarding the Multiple Statements On 1 Line: the following returns ss correctly

    Uses "console"
    Dim st As String
    st = test
    PrintL st
    WaitKey
    Function test() As String
    Dim ss As String : ss="thin" 
    If(Len(ss)>0) Then : ss=ss+"basic" : End If: Return ss 
    End Function
    
    Attached Files Attached Files

  5. #15
    Zak,

    hi john,
    I think your reply was meant for peralta_mike rather than me.

    John
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  6. #16
    sorry John yes it is to peralta_mike

  7. #17
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    Rep Power
    10
    Dear Mike,

    I think you are right regarding credibility of : as statement termination because there are some cases (for example END IF) in which parser checks for <EOL> token and doing that bypass whatever in between.

    I will check what I can do to improve code parsing for those situations. In the meantime leave "Return" and "End If" statements on its own line.

    That said, I personally would avoid writing code all in one line as much as possible. This mainly for code readability and code maintenance.
    There is a great visual difference between
    function setutxtmp(text2 as string) as string
    static utxtmp as string = "utx.tmp"
    if(len(text2)>0) then : utxtmp=text2 : end if : return utxtmp
    end function
    
    and

    function setutxtmp(text2 as string) as string
      static utxtmp as string = "utx.tmp"
      if(len(text2)>0) then
        utxtmp=text2
      end if
      return utxtmp
    end function
    

    In any case, I've opened a bug report:
    http://www.thinbasic.com/community/p...hp?issueid=274

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  8. #18
    Member
    Join Date
    Jul 2010
    Location
    Phoenix, Arizona, usa
    Age
    74
    Posts
    54
    Rep Power
    19

    Smile Thanks Eros.

    Thanks again Eros.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Multiple Conditions in IF/THEN Statements
    By catventure in forum thinBasic General
    Replies: 4
    Last Post: 14-11-2005, 22:59

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •