Alpha Video Training
Results 1 to 3 of 3

Thread: How to pass a parameter to an Xbasic function?

  1. #1
    Member
    Real Name
    David Dukes
    Join Date
    Dec 2012
    Location
    Florida, USA
    Posts
    73

    Default How to pass a parameter to an Xbasic function?

    Currently, I have 7 separate Xbasic functions that do exactly the same thing except each works with a different fieldname (Photo1, Photo2, Photo3, etc.). I would like to consolidate these into one function and pass in the fieldname as a parameter. The functions are called using an Ajax callback from a button on the UX dialog. I've listed the first 2 functions below as an example so you can understand my question. I would like pass in 'Photo1' and 'Photo2' and replace a <placeholder> as in the final example. I'm sure this is easy so I'm hoping someone can help. Thanks in advance.

    function deleteJewelryImage1 as c (e as p)
    dim myID as n
    myID = e.dataSubmitted.STOCKID
    dim sql as c
    sql = "update dbo.Inventory set Photo1 = null, Photo1thumb = null where StockID = :myStockID"
    dim args as sql::arguments
    args.add("myStockID",myID)
    dim cn as sql::Connection
    cn.open("::Name::jta")
    dim flag as l
    flag = cn.Execute(sql,args)
    cn.close()
    end function

    function deleteJewelryImage2 as c (e as p)
    dim myID as n
    myID = e.dataSubmitted.STOCKID
    dim sql as c
    sql = "update dbo.Inventory set Photo2 = null, Photo2thumb = null where StockID = :myStockID"
    dim args as sql::arguments
    args.add("myStockID",myID)
    dim cn as sql::Connection
    cn.open("::Name::jta")
    dim flag as l
    flag = cn.Execute(sql,args)
    cn.close()
    end function

    function deleteJewelryImage as c (e as p)
    dim myID as n
    myID = e.dataSubmitted.STOCKID
    dim sql as c
    sql = "update dbo.Inventory set " + <placeholder> + " = null, " + <placeholder> + "thumb = null where StockID = :myStockID"
    dim args as sql::arguments
    args.add("myStockID",myID)
    dim cn as sql::Connection
    cn.open("::Name::jta")
    dim flag as l
    flag = cn.Execute(sql,args)
    cn.close()
    end function
    Last edited by TheDuke; 08-31-2013 at 09:10 PM.

  2. #2
    "Certified" Alphaholic
    Real Name
    Chris Tappan
    Join Date
    Jun 2009
    Location
    Marietta, GA
    Posts
    1,296

    Default Re: How to pass a parameter to an Xbasic function?

    I may be off slightly on my syntax, but in the Ajax callback help info you can get info. In the last parameter of the Ajax callback, put '_Photo1' or '_Photo2' (in single quotes), etc.

    Then in the function itself, just add this:

    PhotoNum = e._PhotoNum
    sql = "update dbo.Inventory set " + PhotoNum + " = null, " + PhotoNum + "thumb = null where StockID = :myStockID"

  3. #3
    Member
    Real Name
    David Dukes
    Join Date
    Dec 2012
    Location
    Florida, USA
    Posts
    73

    Default Re: How to pass a parameter to an Xbasic function?

    Thanks Chris. I just realized I had the beginning single quote in the wrong place in the Ajax callback. I had _photoNum = 'Photo1' instead of '_photoNum = Photo1'. Anyway, it's working now. Thanks again for the reply.

Similar Threads

  1. Syntax question: pass new record id through xbasic function into email template
    By cptutrecht in forum Application Server Version 11 - Web/Browser Applications
    Replies: 5
    Last Post: 03-20-2013, 04:10 AM
  2. howto pass session parameter to alphaADO
    By GarthMc in forum Application Server Version 10 - Web/Browser Applications
    Replies: 5
    Last Post: 04-26-2010, 04:22 PM
  3. Pass parameter to web page
    By ChristJC in forum Application Server Version 9 - Web/Browser Applications
    Replies: 7
    Last Post: 10-06-2009, 01:07 AM
  4. Function Parameter calling bug?
    By csda1 in forum Alpha Five Version 5
    Replies: 0
    Last Post: 07-29-2004, 09:48 AM

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
  •