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

Xbasic Find a Record and Manipulate that record

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

    Xbasic Find a Record and Manipulate that record

    I have always manipulated a field on a form to make a change to a record, however I was interested on expanding my xbasic limited skills. I have hunted around the board and have not found what I was looking for.

    I would like to get the currently selected record from a browse. (I have never been clear on recno and is this a number that cannot change or would I have to rely on a auto incremented field to get the unique record?


    So,
    1. Get a unique ID for the record
    2. Find that record
    3. How to either get field values or write field values
    4. Save the record.

    Bonus:
    I remember reading some xbasic command to read all fields from a record into some sort of array. So, a variation to the above,
    1. Get a unique ID for the record
    2. Find that record
    3. Read all the records into an "array"
    4. Manipulate the "array" (change a field in it)
    5. Replace the record with the new values in the array or the entire record (this may not be a good idea, let me know)
    6. Save the record.

    I thought I could use one of these to create an xdialog box with variables for each field I would like to change, then write the changes to the record.

    Thank you in advance. I know this is simple and basic for most, but not for me.

    #2
    Re: Xbasic Find a Record and Manipulate that record

    Not sure what the benefit of any of that would be. Nice to learn more xbasic, better if it is useful and helpful.

    Select a record in an embedded browse. Use the Form menu, Zoom to record. What more could you want?
    There can be only one.

    Comment


      #3
      Re: Xbasic Find a Record and Manipulate that record

      Stan,

      There are a couple of times I think this may be helpful. Specifically, In creating an audit function that I needed using the onarrive and onchange events, I have run into issues of record deletions that has forced me to try other things, and this was a thought. To be able to read in all the variables into an array and then compare them, would be a simple test to check if the record has changed any and the need to write to the audit trail. I also thought that an xdialog could be the way to go for some data entry vs. a form. Instead of presenting the user with 40 fields to edit. I would like to only present two at a time to enter and instead of creating 20 forms to edit the segements of data, I could use one xdialog with variables. The zoom to form does not let you center the form on the screen as well.

      This seems like a simple database task that I could employ in other instances aside from a browse situation, where a simple manipulation of a record would be required. Just thought it might be a simple tool to use if necessary.

      Comment


        #4
        Re: Xbasic Find a Record and Manipulate that record

        This seems like a simple database task
        If it were that simple there would probably be an action script element to do it.
        There can be only one.

        Comment


          #5
          Re: Xbasic Find a Record and Manipulate that record

          Difficult to do this, unless you're using events based on the underlying table. (even then, not what you might expect)
          However, I was able to create a "hidden button" field (looks like a regular field) on a browse. When you click on it, the browse event event fires, and presents a user with data entry.
          You could substitute similar code to manipulate the data instead. I had always learned that using recno() was not a good thing, particularly in multi-user environments. (So I use an index/unique field instead.) ~ Aside from that, it's just a matter of coding the hidden button "event event."

          If you inspect/edit the hidden cell button display format builder, you will see how it was built.
          Before doing this, try changing the quantity fields on the browse to different amounts. (3 different "custom buttons" styles appear, depending upon whether you select 0,2, or other quantities)

          Here's the code that I used to read and write to the field. (You can read/written to any field of the record using this method, regardless of which column the "hidden button" is placed.)
          The only thing the user must do, is click on the right field to fire the "hidden button" event.....
          Most of the framework for this code is automatically created when you place a button on the browse.
          Note: The field name is "Quantity", even though the field description on the browse is "Quan."
          Also, within a browse, "specific fields" are addressed as objects. Hence the usage of this:quantity.value where "this" refers to the browse, quantity refers to the quantity field, and value refers to the data in the field. ~ For instance you could also work with the price using "this:price.value".....

          The following function ties in with the buttons "field object name." (The "Quantity" browse field object gets a function named "Quantity_ButtonClick" which fires when the browse object button is clicked.)

          Code:
          [COLOR="#FF0000"]FUNCTION [B]Quantity[/B]_ButtonClick AS V ( event AS C, data AS C , row AS N )
          	
          	msgbox(event)
          'DESCRIPTION: Fired when a button is clicked on a column.
          'Arguments:	event	- the name of the event that is fired
          '			data	- the data in the column cell
          '			row		- the row number in the browse
          	this.Set_Viewport_row(row)[/COLOR]
          
          [COLOR="#FF0000"]'Code in red is added automatically when embed a button on a browse.  For a while, it wasn't in v.11, as that was another bug.[/COLOR]
          [COLOR="#0000CD"]'The following blue code is what is important....[/COLOR]
          
          	[COLOR="#0000CD"]vc_Value=ui_get_number("QUANTITY:","Sold",str(this.quantity.value),"")[/COLOR] 'prompts user for new value when this "hidden button" is clicked
          	'vc_Value=ui_get_number("QUANTITY:","Sold",this:quantity.text,"") 'might have to be used instead if this is a text field.  ui_get_text() is another option for text fields
          [COLOR="#0000CD"]	if vc_value="" then
          		this:quantity.value=1 ' works when "hidden button" is clicked to set value and user exits without making an entry.  (sets default value to 1 during editing)
          		 end
          	end if
          
          	vn_value=val(vc_value) 'convert user entered text value to match quantity field type
          	this:quantity.value = vn_Value ' puts new value into browse field
          	this.Set_Viewport_row(row+1) 'moves to next record in browse[/COLOR]
          	this.next() 'moves to next column (just for show)
          	
          	if this.Table_Get().Mode_Get() > 0 then '(kind of optional, writes field value to database)
          		this.Commit()
          	end if
          		
          	Invoice:browse1:actions.fill.color="red" 'just for show on how to change another field attribute
          
          'because the button display in this quantity field is "conditional", the event value shows what style of button (there are 3) was selected.  (next 3 lines)
          if event	= btnTiny then
          	msgbox(event)
          end if
          
          [COLOR="#FF0000"]END FUNCTION[/COLOR]
          You'll see that the button in the preview (screen capture below) looks "trashed" even though it works and is written properly. (Talk about a PITA)... Couldn't see it, just had to know how to "script it." This is just another bug Alpha decided wasn't worth fixing..... (Problems like this exist "everywhere" if you look hard/deep enough.... I gave up caring, as it became obvious that they didn't.)
          Snap 2013-12-26 at 20.25.16.png


          Finally, once you get the value of the unique field for that row, you can do almost anything with that record in the table. (And then just "resynch" the browse.)

          AlphaSports1011invoice-2013bak.a5pkg
          If you import this into the a5 AlphaSports (v.11, and possibly 10 where it was originally created) it creates a new invoice form with a different name...
          There are several different examples added to this which might be of use. A little "disorganized" & weak on documentation with some "dirty code", as I kept running into bugs as I was learning via "trial and error....... FYI: It's because of many bugs like these (and other issues) that I am pursuing alternative solutions.

          Hope this helps...
          Last edited by SNusa; 12-26-2013, 11:16 PM.
          Robert T. ~ "I enjoy manipulating data... just not my data."
          It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
          RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

          Comment


            #6
            Re: Xbasic Find a Record and Manipulate that record

            Robert,

            Thank you. I hope I am not sounding to newbie, but how do you import that file. I looked through the various menus and I could not find anything that fit the bill.

            Never Mind, sorry, figured that out, looking at it.
            Last edited by johngtatp; 12-26-2013, 10:27 PM. Reason: I lack essential skills

            Comment


              #7
              Re: Xbasic Find a Record and Manipulate that record

              Robert,

              This is interesting and there are some neat things that may be useful elsewhere, thank you.

              Comment


                #8
                Re: Xbasic Find a Record and Manipulate that record

                Over the years, I have created quite a few of these "cheat sheets" which serve as examples of "key" desktop based functionality. (I use/used them for reference.)
                (Submitted an absurd IMO amount of bug reports, of which most "used to get acknowledged, addressed & resolved.")

                I don't know where you are with regards to XBasic, but I found that understanding a few "key concepts" really made all the differences with regards to being able to "work the gui." The key concepts (for me) were: Pointers, aliases & enumeration (so that code is "portable" / addressing is relative and thus won't break.) The CDSA website (hints and tips) was a great help in providing direction too. ~ I figured that if really understood xBasic, the rest would come easy.

                PS: I produced a "mini application" tracking ALL the events fired within a browse (using the table and field based events directly as triggers to register the events.) The little utility displayed all the events on-screen (in a list) in real time. (It included the A_DELETING_RECORD flag.) I did this in response to realizing certain event(s) were not triggering (at the browse level) when the cursor enters the brows at the first record. (I think there were some other oddities too.) There is in fact a bug (several actually) within the desktop browse. (Hint: You NEVER want to rely on a browse that has the "parent record only" property "unchecked." I'd have to check my notes to remember the details of these browse related issues, but some were real deal-breakers. ~ The thing is, I created this "invisible button" (while experimenting) on a browse so that I could still use browses for data entry. (So many others avoid them because of these browse issues.) ~ Fortunately, this solution (the invisible button, or any button for that matter) always seems to fire as expected, and thus seems to work without any issues. So with code added to perform field edits (in a browse) like this, the browse issues are seemingly "circumvented." ~ I think......

                And don't forget to watch the script recorder while navigating and "running a form" using tools in the menu. (Lots of good insight there to as to how things "get done!")
                (I don't know why they didn't/don't teach this stuff. Not even in the xBasic webinars!

                Another thing they don't tell you is to hold the shift and the ctrl keys down when opening a database. ~ "Debug Mode"
                (This gives the option to bypass the autoexec.bat and run settings so you always end up in "build mode")

                Snap 2013-12-26 at 23.34.52.png
                Last edited by SNusa; 12-27-2013, 12:36 AM.
                Robert T. ~ "I enjoy manipulating data... just not my data."
                It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                Comment


                  #9
                  Re: Xbasic Find a Record and Manipulate that record

                  Originally posted by johngtatp View Post
                  Robert,

                  This is interesting and there are some neat things that may be useful elsewhere, thank you.
                  I've got about 5 other "forms" like that which work with AlphaSports. (Not well documented, but the can be dissected to see how they work, as all events are attached to buttons with names.) A while back I though about accounting packages & POS systems (many of which I 'm quite familiar with), and how they operated..... I based a lot of my learning based on thinking: "What would one need to do with a5 in order to recreate the functionality of one particular accounting package."... A package I had used for over a decade. (So with determination and countless hours off training available to "subscribers", I set out and "learned" this core set of desktop capabilities in xBasic. ~ Without relying on wizards and "action scripting!")

                  ~Best of luck.
                  Last edited by SNusa; 12-27-2013, 12:26 AM.
                  Robert T. ~ "I enjoy manipulating data... just not my data."
                  It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                  RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                  Comment

                  Working...
                  X