Alpha Video Training
Results 1 to 7 of 7

Thread: Variable is of different type

  1. #1
    Member
    Real Name
    Ken Boucher
    Join Date
    Feb 2006
    Location
    Manchester, CT
    Posts
    200

    Default Variable is of different type

    I am getting errors in regard to data types and hopefully someone can see why. I have 2 tables (noted below) both with the field Transaction_no and both designating it as numeric.

    Error 1
    When I run the below code I get "Variable is of different type"" for the dim transaction_no as n line

    Code:
    <%a5
    '? "Transaction"+session.transaction + "<br>"
    '? "Session User Name"+session.User_Name+  "<br>"
    '? "Session User Id" +session.USer_Id + "<br>"
    'end
    
    dim tbl_dest as p
    dim tbl_from as p
    dim myindex as p
    dim transaction_no as n
    dim From_User_id as c
    
    Transaction_no=session.transaction
    From_User_Id=session.User_Id
    
    '?transaction_no
    '?From_User_id
    'end
    
    tbl_from = table.open("[PathAlias.ADB_Path]\swap_transactions.dbf",FILE_RW_SHARED)
    tbl_dest = table.open("[PathAlias.ADB_Path]\feedback.dbf",FILE_RW_SHARED)
    myindex1 = tbl_dest.index_primary_put("Transaction_no")
    
    tbl_dest.fetch_find(transaction_no)
    tbl_from.fetch_find(transaction_no)

    Error 2

    When I change that dim statement to 'c' I then get;

    Error:Script: /Feedback.a5w line:38
    tbl_dest.fetch_find("transaction_no")
    Conflicting expression data types


    Which makes sense to me. I truly don't understand why I get Error 1.

    Any insight?
    Ken

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

    Default Re: Variable is of different type

    session vars are always charactor values. Use this:

    Transaction_no=convert_type(session.transaction,"n")
    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)

  3. #3
    Member
    Real Name
    Ken Boucher
    Join Date
    Feb 2006
    Location
    Manchester, CT
    Posts
    200

    Default Re: Variable is of different type

    Thanks for the clarification-

    I added that line right after;

    "Transaction_no=session.transaction"

    to convert it but got the above Error 2 again.

    Script Error
    Error:Script: /Feedback.a5w line:40
    tbl_dest.fetch_find(transaction_no)
    Conflicting expression data types


    Am I putting it in the right place?

    Ken

  4. #4
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,629

    Default Re: Variable is of different type

    Ken,

    i think you want to use the conversion instead of the equality. So instead of putting it after the "Transaction_no=session.transaction" statement, use it instead of the statement.

    Pat

  5. #5
    Member
    Real Name
    Ken Boucher
    Join Date
    Feb 2006
    Location
    Manchester, CT
    Posts
    200

    Default Re: Variable is of different type

    When I try that I get;

    Error:Script: /Feedback.a5w line:25
    dim transaction_no as n
    Variable is of different type


    Ken

  6. #6
    Member
    Real Name
    Martin Horzempa
    Join Date
    Oct 2005
    Posts
    224

    Default Re: Variable is of different type

    hi Ken

    i think that you have a simple naming problem here

    dim transaction_no as n


    tbl_from = table.open("[PathAlias.ADB_Path]\swap_transactions.dbf",FILE_RW_SHARED)
    tbl_dest = table.open("[PathAlias.ADB_Path]\swap_transactions.dbf",FILE_RW_SHARED)
    myindex1 = tbl_dest.index_primary_put("Transaction_no")


    i'll bet dollars to donuts that the actual field in the tables
    swap_transactions.dbf and feedback.dbf is also named transaction_no

    if thats the case then you have actually tried to use the same variable twice
    a big no-no
    you are trying to confuse Alpha5 and its not having any of that
    you should try to use a nameing convention that would avoid this

    i would do something like

    dim mytnumber as N
    mytnumber = session.transaction

    then use this variable for the find operation

    tbl_dest.fetch_find(mytnumber)
    tbl_from.fetch_find(mytnumber)


    also unless you have a typo
    you dimmed
    dim myindex as p
    but used
    myindex1 = tbl_dest.index_primary_put("Transaction_no")
    for the find operation

    you also might need to set the index pointer for the second table also
    dim myindex2 as P
    myindex2 = tbl_from.index_primary_put("Transaction_no")
    tbl_from.fetch_find(mytnumber)


    hth

  7. #7
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,644

    Default Re: Variable is of different type

    www.jollygreenthumb.com

    If you look at your homepage using FireFox, the text at the bottom half is scambled.

Similar Threads

  1. variable type mismatch
    By Ruth Asfaw in forum Alpha Five Version 5
    Replies: 6
    Last Post: 01-20-2005, 08:49 AM
  2. Variable type
    By BRIAN GRAY in forum Alpha Five Version 5
    Replies: 2
    Last Post: 08-26-2004, 06:39 AM
  3. Variable type mismatch
    By Barb Hill in forum Alpha Five Version 5
    Replies: 10
    Last Post: 02-25-2004, 02:47 AM
  4. variable type mismatch
    By hcdoe in forum Alpha Five Version 5
    Replies: 4
    Last Post: 01-26-2004, 03:26 PM
  5. Variable Type
    By James Peterson in forum Alpha Five Version 4
    Replies: 3
    Last Post: 06-06-2002, 10:45 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
  •