Alpha Video Training
Results 1 to 7 of 7

Thread: Portable code - relative/explicit file names

  1. #1
    Member
    Real Name
    Steve T
    Join Date
    Aug 2001
    Location
    UK
    Posts
    13

    Default Portable code - relative/explicit file names

    I am not an Alpha 5 developer, and am posting this on behalf of a colleague...

    Are there guidelines as to 'best practices' in making code portable between different deployment scenarios?

    My colleague has hust hit a problem in a network environment whereby client PCs receive error messages when system cards are run - the problem would appear to be where the card explicitly states the full path to the bdf file. In this particular case the data resides on the server in C:\appName\. C:\appName\ has then been set up as a share as S: on the client pc's. It would then appear that when the system card runs and tries to use the explicit C:\appName\...dbf table, the table cannot be found as C:\appName does not exist on the client.

    Also my colleage has also 'split' the data and created a subdirectory under appName called 'accounts' where he has put all the accounts related tables. The problem appears to be here, that on the 'system cards', you can either specify the explicit full path of a table OR the tableName.dbf. How then, in this case where accounts/tableName.dbf needs to be specified, can I do that? What a relative path list that is specified in the card, the Save throws an error. So, in this case it seems the only option is to enter a full path - but that then causes the issue above re portability.


    Obviously something is being missed this end that's causing the confusion.


    Sorry if the explanation is a bit garbled - I'm not too sure of the Alpha 5 terminology etc.

  2. #2
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,026

    Default Re: Portable code - relative/explicit file names

    my opinions.

    1. all data should be in one folder

    2. mostly where alpha inserts a hard path, you can take the path part out and leave the table or name and it works.

    3. Put no hard paths in unless absolutely necessary and if necessary, make sure what you pathed is where it needs to be.

    there are other ways and sure you will hear from others. I have to go to a meeting now.
    Dave Mason
    dave@aldausa.com
    Skype is dave.mason46

  3. #3
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: Portable code - relative/explicit file names

    Quote Originally Posted by SteveT View Post
    I am not an Alpha 5 developer, and am posting this on behalf of a colleague...

    Are there guidelines as to 'best practices' in making code portable between different deployment scenarios?

    My colleague has hust hit a problem in a network environment whereby client PCs receive error messages when system cards are run - the problem would appear to be where the card explicitly states the full path to the bdf file. In this particular case the data resides on the server in C:\appName\. C:\appName\ has then been set up as a share as S: on the client pc's. It would then appear that when the system card runs and tries to use the explicit C:\appName\...dbf table, the table cannot be found as C:\appName does not exist on the client.

    Also my colleage has also 'split' the data and created a subdirectory under appName called 'accounts' where he has put all the accounts related tables. The problem appears to be here, that on the 'system cards', you can either specify the explicit full path of a table OR the tableName.dbf. How then, in this case where accounts/tableName.dbf needs to be specified, can I do that? What a relative path list that is specified in the card, the Save throws an error. So, in this case it seems the only option is to enter a full path - but that then causes the issue above re portability.


    Obviously something is being missed this end that's causing the confusion.


    Sorry if the explanation is a bit garbled - I'm not too sure of the Alpha 5 terminology etc.
    http://support.alphasoftware.com/alp...EXE_PATH().htm

    http://support.alphasoftware.com/alp...TER_PATH().htm

    http://support.alphasoftware.com/alp...GET_PATH().htm

    http://support.alphasoftware.com/alp...ATE_PATH().htm

    http://support.alphasoftware.com/alp...RED_PATH().htm

    I linked several xbasic functions that will return paths. Depending upon what it is you are wanting you can use these as the starting point for creating the path via xbasic.

    A general rule of thumb that I follow is that everyone connects to the database in the same way. If some of the users connect to the database via the S:\ drive mapping then all of the users need to connect via the same way. If the database is hosted on the C:\ drive for one machine you should go ahead and map the s:\ drive to point back to the C:\ drive. Then access the database via the S:\ drive. By following this guide line you can cheat and hardcode your paths into the scripts. Keep in mind cheaters usually get caught and being caught cheating can carry unforeseen costly penalties.

    In the long run it is easiest to have your paths built dynamically in the xbasic script using the above linked functions as a starting point.

    Example
    Code:
    A5.GET_PATH()+chr(92)+"accounts" +chr(92) + "table_name.dbf"

  4. #4
    "Certified" Alphaholic Tom Henkel's Avatar
    Real Name
    Tom Henkel
    Join Date
    May 2002
    Location
    New Jersey, USA
    Posts
    1,877

    Default Re: Portable code - relative/explicit file names

    My colleague has hust hit a problem in a network environment whereby client PCs receive error messages when system cards are run - the problem would appear to be where the card explicitly states the full path
    Just a quick question...

    You said system CARDS. What version of the software is being run here?

    The CARD System was an old ver 1 method of creating an application. I still use it, but in ver 8, it is much different. In ver 1, there was an application instead of a "database", and a "database" was what ver 8 users call a "table".

    Those differences could influence the way that we respond to the questions.

    Tom

  5. #5
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,026

    Default Re: Portable code - relative/explicit file names

    When connecting your application to the server(I hope you are using shadowed), it is somewhat better9my opinion) to use

    \\name of server\foldername\adbname(like sales.adb)
    if you are not shadowing, there are a whole lot of worms that are out of the can.

    More information is needed before anyone can give you a lot of help here. We are all guessing, alt least I am.

    terminology help

    adb file is your alpha database
    dbf is a table

    As tom said, cards are rarely used anymore and could disappear in a future version. It is best to get away from them asap if that is in fact what you are using.

    all you data should be accessible in your shadowed copy that would be available from the server. If you have bitmaps or other files that are not included in the shadow, you can specify those files to be included which would copy them over to the user machine or you can manually copy them over.

    As andrew said you can put in a path()(among others) statement or other instead of a hard coded path to retrieve the data.

    A little searching of the help files can be a blessing.
    Dave Mason
    dave@aldausa.com
    Skype is dave.mason46

  6. #6
    Member
    Real Name
    Steve T
    Join Date
    Aug 2001
    Location
    UK
    Posts
    13

    Default Re: Portable code - relative/explicit file names

    All,
    Thanks for all the replies.

    The Alpha version being used is 7.
    What I mean by 'system card' is where you use a predefined process to perform an action such as an append or post.
    To me, a table is a collections of related rows (a row a set of related columns) and a database is a collection of related tables.

    The application is being accessed from two distinct 'routes' - ie from network attached PCs where they connect to the database via a network shared drive (ie S:\appName\....) and also directly from the server (where the connection is direct to the C:\appName\ drive). This is what first highlighted the issue - as a user running an 'append' card from the server worked fine, but the same card being run from the networked PCs failed as the append card had an explicit path to a table (the assumption then being that the append would be looking for the C:\appName\.... table specified in the card on the 'client' PC - where that directory/table never existed).
    To compound the problem - the application (for legacy reasons) has the database split in two directories - the main C:\appName\... location and also a subdirectory under that called Accounts. The Accounts sub folder then carries (as you may have guessed) accounting related tables. The secondary issue then was that in the 'cards' - the table definitions didn't allow for relative paths. For example if my main table was C:\appName\table1.dbf and I want to append from table2.dbf that happens to be in accounts, I cannot specify just Accounts\table2.dbf - I can either specify table2.dbf (ie without any path at all and Alpha appears to assume the path of the table being appended to) or I can specify the full path to the table (ie C:\appName\Accounts\table2.dbf) - which then gives me the catch 22 with client-server type access.

    Does that make it any clearer? (Like mud eh?)

  7. #7
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,026

    Default Re: Portable code - relative/explicit file names

    Your term, "card" is called an "operation". it would help you here to use that.

    The append can be turned into a script, which is another matter.

    before the append, a little code can get you a hard path to that table(s) by using the functions provided above into a variable. In the append you can use that variable(I think) along with that table name and it should work. i have not tried that, but see no reason it cannot work. if it doesn't, you could convert the operation to a script and do it there. a script will work faster than an operation in almost all cases and a function will go even faster.

    example append from one of mine:
    Code:
    DIM Append as P
    ' now the "inv"could be doe with  my already defined variable "cpath2" that has "c:\ups55\folder\" in it to
    'a_tbl = table.open(alltrim(var->cpath2)+"inv")
    
    'below is real like i use it
    
    a_tbl = table.open("inv")
    append.t_db = "inventor"
    'ON ERROR GOTO ERROR24092007170516515
    
    
    append.m_key = "Stock"
    append.t_key = "Stock"
    append.m_filter = ""
    append.t_filter = ".not.isblank(\"stock\").and..not.isblank(\"pdate\").and..not.isblank(\"make\").and..not.isblank(\"vin\").and.len(stock)>=4.and.date()-pdate<365"
    append.type = "Unique only"
    append.m_count = 2
    append.m_field1 = "Lot"
    append.m_exp1 = "Var->lot"
    append.t_count = 0
    
    a_tbl.append()
    
    a_tbl.close()
    i see there was a reason the folders were split and suggest it be rethought. Just because tables share the same folder does not make them any more/less usable or in any way shared by the others, but can drastically help processes as you can see now.
    Last edited by DaveM; 02-02-2008 at 10:08 AM.
    Dave Mason
    dave@aldausa.com
    Skype is dave.mason46

Similar Threads

  1. Alpha won't let me duplicate tables as relative file paths
    By spain246 in forum Alpha Five Version 7
    Replies: 8
    Last Post: 11-06-2007, 03:37 PM
  2. Replies: 10
    Last Post: 06-13-2007, 07:59 AM
  3. Relative file paths
    By csda1 in forum Archived Wishlist
    Replies: 0
    Last Post: 09-01-2005, 06:59 AM
  4. Changing set locations to Relative File Paths
    By spain246 in forum Alpha Five Version 6
    Replies: 3
    Last Post: 08-23-2005, 01:53 PM
  5. Import and relative file delete
    By spain246 in forum Alpha Five Version 6
    Replies: 13
    Last Post: 06-02-2005, 10:11 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
  •