Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Never make a field name = a table name

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Raymond Lyons
    replied
    Re: Never make a field name = a table name

    Stan,

    All I will say is, I think more of what you have shown in this thread should be accessible in the Help file. Yes, there is some stuff there related to all this, but not much, and what I found was not particularly helpful. But maybe that's just me.

    Thanks for sharing.

    Ray Lyons

    Leave a comment:


  • Stan Mathews
    replied
    Re: Never make a field name = a table name

    I just like to explore.

    Again from the interactive, in AlphaSports. I see the rules as something like a multilevel pointer variable.

    Code:
    tbl = table.open("invoice_items")
    rul = table.rules_get()
    ? rul [COLOR="#0000FF"]'methods and properties of the rul pointer
    [/COLOR]= candidate_key as C()  'Returns a cr-lf delimited list columns that make up the best candidate for 'key column'.
    V Change_Begin()  'Begin changes to the field rules.
    V Change_End([L Commit])  'End changes to the field rules.
    C Class()  'Get the class name.
    Dependencies_Get as C(tableName as c,fieldName as c)  'Returns a cr-lf delimited list of dependencies in the field rules on a column on a foriegn table - list generate in format <tablename>|<fieldname>|<reason>.
    Field_Rule_Get as P(fieldName as c[,variableFrame as p])  'Get (or add) a rule for a field - includes variables of calc fields.
    V Mode_Get()  'Get change/view mode of field rules.
    Table_Dependencies_Get as C()  'Returns a cr-lf delimited list of all the external tables that are referenced by field rules for tables - of the form <tablename>|<reason>.
    L Tag_Add(C table,C order_expre,C filter_expr,L unique)  'Add a tag if it doesn't already exist.
    +Code.
    +EXTENSION.
    +INVOICE_NUMBER.
    +PRICE.
    +PRODUCT_ID.
    +QUANTITY.
    
    ? rul.EXTENSION[COLOR="#0000FF"] 'methods and properties of the rul.extension pointer
    [/COLOR]= C Class()  'Get the class name.
    constraints_get()
    constraints_types()
    data_type_get()
    from_string()
    fullname_get()
    generate_script()
    name_get()
    table_name_get()
    to_string()
    Auto_Advance = .F.
    Calc = "QUANTITY*PRICE"
    Case_Convert = "None"
    Case_Lookup_Word = "Entire"
    Check_Case_Exceptions = .F.
    +Code.
    +Cross_File.
    Cursor_Pos = "End Of Selected"
    Data_Type = "Calc"
    +Default.
    Description = "Quantity x Price"
    +Double_Entry.
    Long_Name = "Extension"
    +Lookup.
    +Mask.
    Maximum = ""
    Minimum = ""
    +Post.
    +Required.
    Skip = ""
    Template_Not_Stored = .F.
    +Unique.
    +Validation.

    Leave a comment:


  • Al Buchholz
    replied
    Re: Never make a field name = a table name

    Stan's the smart one.

    I'm just bullheaded and scratch until I come up with something and then ask Stan what I should have done.

    Leave a comment:


  • Raymond Lyons
    replied
    Re: Never make a field name = a table name

    Stan,

    Thanks. A code snippet like yours in the help file for a calc field rule would have been a big help. Not sure how I'm going to deal with my issue yet but what you gave certainly works (of course!)

    Al,

    I did look at Dictionary Functions and Methods in the so-called Help file. I may have missed something but I didn't find anything that indicated that the key to making a change in a Calc field rule was the "Calc" in rul.fieldname.Calc. Of course if I were as smart as you and Stan, I probably would have guessed that and tried it. On the other hand my thought of going with an append to a table with the proper field rule already in it meant I could avoid the EXTREME frustration I have every time I open the so-called help file! For me the help files from 10 to 15 years ago were far more helpful. I believe they had many more example code snippets in them, though I could be wrong.

    Ray Lyons

    Leave a comment:


  • Stan Mathews
    replied
    Re: Never make a field name = a table name

    Done in the interactive for demo purposes.

    Code:
    tbl = table.open("dest")'table pointer
    rul = tbl.rules_get() 'rules pointer
    ? rul.tst.Calc 'show the calculation set for the tst field, wouldn't do this in actual script
    = "UPPER(ST)"
    
    rul.change_begin()
    rul.tst.Calc = strtran(rul.tst.Calc,"ST","ST_new") 'change the field name from ST to ST_new
    rul.change_end()
    tbl.close()
    Last edited by Stan Mathews; 05-19-2017, 06:46 PM. Reason: edited strtran expression

    Leave a comment:


  • Al Buchholz
    replied
    Re: Never make a field name = a table name

    Look at the Dictionary Functions and Methods

    Leave a comment:


  • Raymond Lyons
    replied
    Re: Never make a field name = a table name

    Stan & Al,

    I have no idea how to change the name of a field that appears in a table field rule calculation using xbasic. I find the new Help file to be next to useless for this (and for most things). Just to be clear, we are not talking about changing the name of a field in a table. What would be needed is the xbasic to change the bogus name that appears in one of the calcs in the table's field rules. I am sure there is an xbasic way but unless someone wants to share a method, I'll just go about using a zap and an append after the temp table is created.

    Ray Lyons

    Leave a comment:


  • Al Buchholz
    replied
    Re: Never make a field name = a table name

    With xbasic you can rename by using the field name or field number.

    You should built a short function to do exactly what you want/need.

    Interesting to note the issue that you found.

    Further evidence that unique names help the readability of code for the user/developer and the application operation...

    Leave a comment:


  • Stan Mathews
    replied
    Re: Never make a field name = a table name

    Obviously I don’t want to have to edit field rules every time the saved copy records operation is run.
    Can be done with xbasic so you don't have to remember/do it manually.

    Leave a comment:


  • Raymond Lyons
    started a topic Never make a field name = a table name

    Never make a field name = a table name

    Never have a field name be the same as the table name in which the field resides.

    Is doing so asking for all kinds of problems? Not in my experience. For 20+ years my breaking this rule in a large complex app never caused a single problem–until a few days ago when I used a Copy Records operation on a table named “Funded” to create a slimmed down temp table I named “Funded_tmp”. The problem arose because the Funded table has a date field also named Funded and the latter is used in a calculated field rule with another date field. The problem is that although “Funded” is a field in the new table, in the new copied field rules the field is named whatever the new table name is, e.g., “Funded_tmp” (or “Zztop” if I named the new table Zztop). The same thing happens if I simply duplicate the table via the A5 Duplicate operation. Sadly it is way too late to simply change the Funded table name or the Funded field name. In a large complex app doing so would be an enormous project, though possibly one of Cal Locklin’s utilities might help in such an endeavor (Cal’s utilities have saved me an enormous amount of time over the years–thanks Cal, if you are still lurking around).

    Of course it would be easy to correct the field name in the copied over field rules. However, I wanted the copied table to be a temporary table that would be recreated weekly with the saved copy records operation. Possibly a bad approach anyway, but that was my original thought. Obviously I don’t want to have to edit field rules every time the saved copy records operation is run.

    Although I have not done it yet, I assume one easy way to deal with this problem would be to use an append to produce my weekly version of the temp table, after fixing field name in the field rules of the initial copied table created by a copy records operation.

    Is this a bug? I suppose so. But Selwyn and Cian have looked at the code involved in a fix and determined that a fix would be “very risky”. So a fix is not going to happen, at least not in the near future. Since in Alpha Five there are lots of ways to skin a cat, I’m fine with cat skinning.
Working...
X