Alpha Video Training
Results 1 to 9 of 9

Thread: xBasic basics: how to enter multi-line commands?

  1. #1
    "Certified" Alphaholic
    Real Name
    Jaime Ben David
    Join Date
    Jan 2011
    Location
    Karkur, Israel
    Posts
    1,097

    Default xBasic basics: how to enter multi-line commands?

    Hi
    I need to create a big command (concatenating the values of 30 controls to create one long string).
    In vfp, i can do something like:
    myString = "somestuff"+"somestuff"+;
    "morestuff"+"morestuff"+;
    "evenmorestuff" ...
    What character do you use in xBasic to tell it the command is continuing in the next line?

    Thanks
    jaime

  2. #2
    Volunteer Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,630

    Default Re: xBasic basics: how to enter multi-line commands?

    myString = "somestuff"+"somestuff"+ \
    "morestuff"+"morestuff"+ \
    "evenmorestuff" ...
    -Steve


  3. #3
    "Certified" Alphaholic
    Real Name
    Jaime Ben David
    Join Date
    Jan 2011
    Location
    Karkur, Israel
    Posts
    1,097

    Default Re: xBasic basics: how to enter multi-line commands?

    Thanks Steve!

  4. #4
    Banned
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,819

    Default Re: xBasic basics: how to enter multi-line commands?

    I believe it's the backslash character

    myString = "somestuff" + \
    "morestuff" + \
    "evenmorestuff"

    I'm just too late today!

  5. #5
    "Certified" Alphaholic
    Real Name
    Jaime Ben David
    Join Date
    Jan 2011
    Location
    Karkur, Israel
    Posts
    1,097

    Default Re: xBasic basics: how to enter multi-line commands?

    Yup, thanks David

  6. #6
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: xBasic basics: how to enter multi-line commands?

    You can also use this method to make your code more readable. It allows you to neatly enter lines of code and then execute them. Search for Code Indirection in the Wiki for other examples:

    somestuff = "steve"
    evenmorestuff = "Wood"
    morestuff = " "
    myString = <<%txt%
    somestuff + somestuff +
    morestuff + "a_literal_string" +
    " " +
    evenmorestuff
    %txt%
    ?eval(mystring)
    = "stevesteve a_literal_string Wood"
    Another example showing you can include xbasic:
    f = "steve"
    l = "Wood"
    fullname = <<%txt%
    upper(f) +
    ' ' +
    l
    %txt%
    ?eval(fullname)
    = "steve Wood"
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  7. #7
    "Certified" Alphaholic
    Real Name
    Jaime Ben David
    Join Date
    Jan 2011
    Location
    Karkur, Israel
    Posts
    1,097

    Default Re: xBasic basics: how to enter multi-line commands?

    Hi Steve
    I am using your suggestion (%txt%) to create a long XML string, but i'm stuck at the following caveat:
    String looks like:
    Code:
    myXml = <<%txt%
     <?xml version="1.0" encoding="utf-8"?>
    <root>
    <tag1>blablabla</tag1>
    <tag2>upper(SomeVar)</tag2>
    </root>
    %txt%
    If i use ? myXml, then the xBasic functions and variables are not evaluated. On the other hand, if i use eval(myXml), it gives me an error - i guess because it's evaluating utf-8 as a variable. How can i have it evaluate the xBasic, but still format the string as "utf-8"

    Thanks
    Jaime

  8. #8
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: xBasic basics: how to enter multi-line commands?

    Sorry, use evaluate_string() and use {} where I show below. I did not notice that my xbasic example actually failed.

    somevar = "steve"

    myXml = <<%txt%
    <?xml version="1.0" encoding="utf-8"?>
    <root>
    <tag1>blablabla</tag1>
    <tag2>{upper(SomeVar)}</tag2>
    </root>
    %txt%

    ?evaluate_string(myxml)
    = <?xml version="1.0" encoding="utf-8"?>
    <root>
    <tag1>blablabla</tag1>
    <tag2>STEVE</tag2>
    </root>
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  9. #9
    "Certified" Alphaholic
    Real Name
    Jaime Ben David
    Join Date
    Jan 2011
    Location
    Karkur, Israel
    Posts
    1,097

    Default Re: xBasic basics: how to enter multi-line commands?

    Thanks!!!

Similar Threads

  1. 2 xbasic commands that I cannot find in the Help file
    By Graham Wickens in forum Alpha Five Version 10 - Desktop Applications
    Replies: 3
    Last Post: 10-08-2011, 09:18 AM
  2. New Xbasic commands and enhancements in version 8.
    By Marcel Kollenaar in forum Alpha Five Version 7
    Replies: 1
    Last Post: 11-01-2006, 05:47 AM
  3. Dynamic evaluation of xbasic commands
    By Mike Thomson in forum Alpha Five Version 5
    Replies: 4
    Last Post: 09-16-2005, 02:42 PM
  4. low level Xbasic commands from script recorder
    By oldtony in forum Alpha Five Version 6
    Replies: 2
    Last Post: 01-21-2005, 01:59 PM
  5. Undocumented Xbasic Commands???
    By Steve Buckler in forum Alpha Five Version 4
    Replies: 2
    Last Post: 04-20-2000, 05:07 PM

Bookmarks

Posting Permissions

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