Alpha Video Training
Results 1 to 12 of 12

Thread: How to continue a statement on next line in xbasic function?

  1. #1
    Member
    Real Name
    Paul Ammoun
    Join Date
    Oct 2012
    Location
    Beirut, Lebanon
    Posts
    229

    Default How to continue a statement on next line in xbasic function?

    Hello,
    How can I continue a statement on next line in xbasic function?

    I have a the following line :
    sqlCommand = "SELECT transact_head.transact_head_id, transact_head.theyear, transact_head.themonth, transact_head.employ_id, transact_head.Abbat, transact_head.abbat_fem, Sum( If( transact_det.taxable = 1 , transact_det.Totalamount, 0) ) AS SumOfTaxable FROM transact_head transact_head INNER JOIN transact_det transact_det ON transact_head.transact_head_id = transact_det.transact_head_id WHERE transact_head.theyear = :whatyear AND transact_head.themonth <= :whatmois GROUP BY transact_head.theyear, transact_head.themonth, transact_head.employ_id, transact_head.transact_head_id, transact_head.Abbat, transact_head.abbat_fem "

    In the editor it does not wrap and I have to scroll right and this makes it very difficult to read and debug I would like to have something that looks like :

    sqlCommand = _
    "SELECT transact_head.transact_head_id, _
    transact_head.theyear, _
    transact_head.themonth, _
    transact_head.employ_id, _
    etc..

    The _ is of course visual basic char to go to next line..

    Thank you

  2. #2
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: How to continue a statement on next line in xbasic function?

    Code:
    sqlCommand = <<%sql%
    SELECT
    transact_head.transact_head_id, transact_head.theyear, transact_head.themonth,
    transact_head.employ_id, transact_head.Abbat, transact_head.abbat_fem,
    Sum ( If( transact_det.taxable = 1 , transact_det.Totalamount, 0) )
    AS  SumOfTaxable
    FROM transact_head transact_head INNER JOIN transact_det transact_det ON transact_head.transact_head_id = transact_det.transact_head_id
    WHERE 
    transact_head.theyear = :whatyear AND transact_head.themonth <= :whatmois GROUP BY transact_head.theyear, transact_head.themonth, transact_head.employ_id, transact_head.transact_head_id, transact_head.Abbat, transact_head.abbat_fem
    %sql%
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

  3. #3
    Member
    Real Name
    Paul Ammoun
    Join Date
    Oct 2012
    Location
    Beirut, Lebanon
    Posts
    229

    Default Re: How to continue a statement on next line in xbasic function?

    Thank you Ghandi

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

    Default Re: How to continue a statement on next line in xbasic function?

    You said "xbasic" in the title but then asked about an SQL query.

    So for an xbasic expression, it is the backslash:

    aa = "test " + crlf() \
    + "me " + crlf() \
    + "out"

    ??aa
    test
    me
    out
    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)

  5. #5
    Member
    Real Name
    Paul Ammoun
    Join Date
    Oct 2012
    Location
    Beirut, Lebanon
    Posts
    229

    Default Re: How to continue a statement on next line in xbasic function?

    Thank you for the reply Steve.
    The question was for xbasic and the sql statement was an example.
    I did not know there was a difference I thought I could use a statement like :

    sqlCommand = \
    "SELECT transact_head.transact_head_id, \
    transact_head.theyear, \
    transact_head.themonth, \
    transact_head.employ_id, \
    etc..

    does this work ? Didn't try it yet..

    I guess I got both answers..

    Thanks again

  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: How to continue a statement on next line in xbasic function?

    No that wont work because that is an sql statement ( being saved to a variable using xbasic.)
    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
    Member
    Real Name
    Ivan Lozano
    Join Date
    Apr 2013
    Location
    Azusa, CA. LA County
    Posts
    400

    Default Re: How to continue a statement on next line in xbasic function?

    Glad I found this post, I ran into the same issue. I have a pretty long sql statement to execute and having it all in one line was getting pretty difficult to read, Thanks Ghandi.

  8. #8
    "Certified" Alphaholic CharlesParker's Avatar
    Real Name
    Charles Parker
    Join Date
    Dec 2012
    Location
    New Orleans, LA
    Posts
    2,140

    Default Re: How to continue a statement on next line in xbasic function?

    I must be missing something in Ghandi's answer, are saying all you gotta do is put a comma OR a sql command to go to the next line in a sql statement?
    NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

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

    Default Re: How to continue a statement on next line in xbasic function?

    No, there is no way to "continue sql on a new line" using what you know from xbasic (the slash bar). Instead, follow what Ghandi was really saying and use 'delimiters' such as <<%txt...%txt% in the simplified examples below:

    dim cn as sql::connection
    vsql = <<%txt%
    SELECT *
    FROM mytable
    WHERE id=1
    %txt%
    cn.execute(vsql)

    or

    dim cn as sql::connection
    myid = 1
    vsql = <<%txt%
    SELECT *
    FROM mytable
    WHERE id={myid}
    %txt%
    vsql = evaluate_string(vsql)
    cn.execute(vsql)

    or

    dim cn as sql::connection
    dim args as sql::arguments
    vsql = <<%txt%
    SELECT *
    FROM mytable
    WHERE id=:myid
    %txt%
    args.add("myid",1)
    cn.execute(vsql,args)
    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)

  10. #10
    "Certified" Alphaholic CharlesParker's Avatar
    Real Name
    Charles Parker
    Join Date
    Dec 2012
    Location
    New Orleans, LA
    Posts
    2,140

    Default Re: How to continue a statement on next line in xbasic function?

    OH I think i get it, so by basically dimming it a txt string you can jump down 3 lines it doesnt matter as the "line break/returns" effectively become "spaces" rather than line breaks?

    Is this correct also?

    Code:
    dim cn as sql::connection
    dim args as sql::arguments
    vsql = <<%txt%
    SELECT *
    FROM mytable
    
    
    WHERE id=:myid
    
    %txt%
    args.add("myid",1)
    cn.execute(vsql,args)
    NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

  11. #11
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: How to continue a statement on next line in xbasic function?

    in addition
    you can indent the way you normally do to make it easy for you align the ifs and end ifs or case statements.

    also the quotes need not be escaped as you need to do in single line statement ( or use the opposite quote)

    and when you want to select individual fields for some reason, you can list them in a field per line to match up the arguments set construct. so you know what are all the fields need arguments and there is no mismatch for alpha to announce it to you that some arguments are not found.

    i use this construct always for the above reasons mostly then also for lengthy statements.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

  12. #12
    "Certified" Alphaholic CharlesParker's Avatar
    Real Name
    Charles Parker
    Join Date
    Dec 2012
    Location
    New Orleans, LA
    Posts
    2,140

    Default Re: How to continue a statement on next line in xbasic function?

    Thanks guys!
    You helped me turn another development corner again.
    Although I feel like a Child in a high tech space craft with the ability to travel anywhere - the controls are marked well enough that I can get where I am going when I have the proper understanding.
    NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

Similar Threads

  1. function to return line number in xbasic script?
    By Steve Wood in forum Application Server Version 11 - Web/Browser Applications
    Replies: 6
    Last Post: 01-24-2013, 08:30 PM
  2. A "Continue" for the "While" statement in XBASIC
    By brett s in forum Archived Wishlist
    Replies: 9
    Last Post: 07-13-2008, 06:02 AM
  3. xbasic function equivalent to SQL statement
    By slamdunk in forum Alpha Five Version 8
    Replies: 4
    Last Post: 11-01-2007, 09:12 AM
  4. Xdilaog continue on new line bug??
    By Mario Prieto in forum Alpha Five Version 6
    Replies: 2
    Last Post: 09-14-2004, 07:54 AM
  5. Continue a script on next line?
    By Jeff Moses in forum Alpha Five Version 4
    Replies: 2
    Last Post: 08-29-2000, 05:55 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
  •