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

Weight Conversion using a Dialog!

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

  • Weight Conversion using a Dialog!

    I have a top screen menu called ‘Information’ with sub-headers – on of these sub headers are called: Weights and Measures, the menu code is set up as:

    Weights and Measures:|Cuft to Cbm / Cbm to Cuft
    Weights and Measures:|-
    Weights and Measures:|Set Up: Density Factors

    Depending on the user they would set up their Density Factor using the following:

    Sea Shipments: 5.5 to 7.0 pounds per cubic foot
    Air Shipments: 10.4 pounds per cubic foot

    The reason a Density Factor is used is because shipments of personal effects are difficult to weigh.

    The Weights and Measures:|Set Up: Density Factors will normally be set up after the installation of the Alpha 5v6 application and will not usually be changed unless an industry change requirement forces the user to do so.

    Once the Density Factor is entered the user would then select the Weights and Measures:|Cuft to Cbm / Cbm to Cuft to convert cubic feet to cubic meters and vice versa.

    I want the dialog to have 2 data entry fields:

    Field 1: Cubic Feet
    Field 2: Cubic Meters

    If a user enters in the Cubic Feet values I want the Cubic Meter field to convert the data, however – if the user enters Cubic Meters in the Cubic Feet field I want the Cubic Feet field to convert the Data also – I only want the two fields displayed in the dialog.

    In addition I will need a Radio Button selection for Sea Shipment and Air Shipment, thus the conversion factors would be drawn in from the Weights and Measures:|Set Up: Density Factors dialog window.

    What is the best approach in creating these two Dialogs? The data in the Density Factors needs to be permanent but if it does not need to link to a specific customer job, thus when the Density Factor is changed it will not effect any previously made customer shipments – this function is to be considered as a Conversion Calculator.

    Andy

  • #2
    RE: Weight Conversion using a Dialog!

    ""I want the dialog to have 2 data entry fields:

    Field 1: Cubic Feet
    Field 2: Cubic Meters

    If a user enters in the Cubic Feet values I want the Cubic Meter field to convert the data, however – if the user enters Cubic Meters in the Cubic Feet field I want the Cubic Feet field to convert the Data also – I only want the two fields displayed in the dialog. ""

    I'd prompt for the volume, then the units, do the calc, and assign the input values and the calc values to Field 1 and Field 2 for display. I would not use Field 1 and Field 2 to both collect the input and do the calc since you can't know in advance which field is receiving input from the user. (More elegant solutions may be "out there". I have a personal tendency to use brute force solutions to all problems, with which I regularly struggle.)

    -- t

    Comment


    • #3
      RE: Weight Conversion using a Dialog!

      Tom,
      thanks for your direct comments, I think you could be correct in your approach but I want to do this a little different. I would like to have just 2 fields (left = cuft and right = cbm).

      If a user wants to know what his 101 cubit feet are in cbm they enter the data in the left field. On the other hand, if they want to know what 55 cbm are in feet they enter the details in the right field. In both cases the opposite field would show the result. The calculation factor is in the Density Factor field entered through the Set Up dialog.

      This would mean the 2 fields would have a dual purpose.

      1. Data Entry
      2. Calculated result.

      May be a two Conditional Objects with 2 data entry and 2 calculation fields placed on top of each other could do the task. I however do not know enough about Conditional Objects to know if this would help.

      Regards
      Andy

      Comment


      • #4
        RE: Weight Conversion using a Dialog!

        Here's a little Xdialog that will allow entry into either box. As you enter a number, the other number is recalculated. This doesn't use the exact formulas you are after, but should get you moving in the right direction.

        dim ft as n = 0
        dim m as n = 0
        ui_dlg_box("conversion",""%dlg%
        Cubic feet|Cubic meters;
        [ft!feet]|[m!meters];
        "close"
        %dlg%,""%code%
        if a_dlg_button = "feet"
        a_dlg_button = ""
        m = 0.02832 * ft
        elseif a_dlg_button = "meters"
        a_dlg_button = ""
        ft = 35.31 * m
        end if
        %code%)

        Lenny Forziati
        Vice President, Internet Products and Technical Services
        Alpha Software Corporation

        Comment


        • #5
          RE: Weight Conversion using a Dialog!

          Hi Lenny,

          You got it spot on, just increased the size of the data entry fields and were there. How to I centralize text in the fields, it this possible?

          'Date Created: 05-Nov-2004 02:27:32 AM
          'Last Updated: 05-Nov-2004 03:03:32 AM
          'Created By : Lenny Forziati
          'Updated By : Andy
          dim ft as n = 0
          dim m as n = 0
          ui_dlg_box("Volume Conversion",""%dlg%
          Cubic Feet|Cubic Meters;
          [16ft!feet]|[16m!meters];
          "close"
          %dlg%,""%code%
          if a_dlg_button = "feet"
          a_dlg_button = ""
          m = 0.0283168 * ft
          elseif a_dlg_button = "meters"
          a_dlg_button = ""
          ft = 35.3146666 * m
          end if
          %code%)

          Thanks
          Andy

          Comment


          • #6
            RE: Weight Conversion using a Dialog!

            Thanks, Lenny.

            I am still a beginner when working with xdialog code. It's hard to get out of the habit of thinking linearly. At first blush I'd think the CODE section of your script would run after the dialog closes. Of course that's wrong. It gets processed each time the change event fires for either text control. This is a new way of thinking for me, and the example helped.

            -- t

            Comment


            • #7
              RE: Weight Conversion using a Dialog!

              Hi Lenny,
              I improved the look of my dialog but I now want to add code to make it Modeless and to have a Rollup feature, this is my current code:

              dim ft as n = 0
              dim m as n = 0
              ui_dlg_box("Volume Conversion",""%dlg%
              {region}
              Cubic Feet: |{line=0,3}{sp=.75}[.16ft!feet];
              Cubic Meters: |{sp=.75}[.16m!meters];
              {line=2,0};
              {endregion};
              {region}
              "12OK" "12rollup"
              {endregion}
              %dlg%,""%code%
              if a_dlg_button = "feet"
              a_dlg_button = ""
              m = 0.0283168 * ft
              elseif a_dlg_button = "meters"
              a_dlg_button = ""
              ft = 35.3146666 * m
              end if
              %code%)

              Any suggestions for adding the Rollup/down feature?
              Regards
              Andy

              Comment


              • #8
                RE: Weight Conversion using a Dialog!

                Andy, the switch to a modeless dialog is quite simple. ui_dlg_box() becomes ui_modeless_dlg_box() and you need to add a "close" event handler that calls ui_modeless_dlg_close() to close the dialog.

                dim ft as n = 0
                dim m as n = 0
                dim dlg_title as c = "Volume Conversion"
                ui_dlg_box(dlg_title,""%dlg%
                {region}
                Cubic Feet: |{line=0,3}{sp=.75}[.16ft!feet];
                Cubic Meters: |{sp=.75}[.16m!meters];
                {line=2,0};
                {endregion};
                {region}
                "12OK" "12rollup"
                {endregion}
                %dlg%,""%code%
                if a_dlg_button = "feet"
                a_dlg_button = ""
                m = 0.0283168 * ft
                elseif a_dlg_button = "meters"
                a_dlg_button = ""
                ft = 35.3146666 * m
                elseif a_dlg_button = "OK"
                ui_modeless_dlg_close(dlg_title)
                end if
                %code%)


                Rollup code is a little more complex, but still fairly simple to do. Take a look in Learning Xdialog, there is a sample in the Misc section. Basically you define two dialogs with the same title and the rollup/rolldown button alternates between dialogs.

                However, I strongly prefer to create MDI Xdialogs. This allows the modeless window to be minimized instead of just rolled up which is probably what your app users are more accustomed to. You can also define menus and toolbars for an MDI window if desired. You'll find an example of this technique in Learning Xdialog as well.

                -Lenny

                Lenny Forziati
                Vice President, Internet Products and Technical Services
                Alpha Software Corporation

                Comment


                • #9
                  RE: Weight Conversion using a Dialog!

                  You're right Tom, Xdialogs don't have the usual linear flow of a typical script. Instead you are essentially designing a form and the code section contains the scripts for each event you would like to define. The code is run each time anything happens in the dialog, such as a user typing or clicking a button.

                  It takes a slight shift in thinking, but it gives you a tremendous amount of power and flexibility.

                  -Lenny

                  Lenny Forziati
                  Vice President, Internet Products and Technical Services
                  Alpha Software Corporation

                  Comment


                  • #10
                    RE: Weight Conversion using a Dialog!

                    Lenny,
                    I have read the information in Learning Exbasic and I have created my Rollup/Rolldown but can work out how to incorporate the following code:

                    if a_dlg_button = "feet"
                    a_dlg_button = ""
                    m = 0.0283168 * ft
                    elseif a_dlg_button = "meters"
                    a_dlg_button = ""
                    ft = 35.3146666 * m

                    This is my current code as it stands:
                    'Date Created: 27-Oct-2002 09:12:46 PM
                    'Last Updated: 27-Oct-2002 09:12:46 PM
                    'Created By :
                    'Updated By : Andy
                    dim ft as n = 0
                    dim m as n = 0
                    dim dialog_box_title as c
                    dialog_box_title = "Volume Conversion"
                    dlg_expanded = ""%dlg%
                    {can_exit=close}
                    {position=remember=test_dialog}
                    {region}
                    Cubic Feet: |{line=0,3}{sp=.75}[.16ft!feet];
                    Cubic Meters: |{sp=.75}[.16m!meters];
                    {line=2,0};
                    {endregion};
                    {region}
                    "12OK" "12Rollup";
                    {endregion}
                    %dlg%

                    dlg_contracted = ""%dlg%
                    {can_exit=close}
                    {position=remember=test_dialog}
                    Click Rolldown to enter data.;
                    {lf};
                    "12OK" "Rolldown";
                    %dlg%

                    event_expanded = ""%code%
                    if a_dlg_button = "OK" then
                    ui_modeless_dlg_close(dialog_box_title)
                    end if

                    if a_dlg_button = "rollup" then
                    ui_modeless_dlg_box(dialog_box_title,dlg_contracted,event_contracted)
                    end if
                    %code%

                    event_contracted = ""%code%
                    if a_dlg_button = "OK" then
                    ui_modeless_dlg_close(dialog_box_title)
                    end if

                    if a_dlg_button = "rolldown" then
                    ui_modeless_dlg_box(dialog_box_title,dlg_expanded,event_expanded)
                    end if
                    %code%

                    ui_modeless_dlg_box(dialog_box_title,dlg_expanded,event_expanded)


                    Can you you help?

                    Regards
                    Andy

                    Comment


                    • #11
                      RE: Weight Conversion using a Dialog!

                      Just add it to the event_expanded, as you want that code to be part of the event handler for the expanded window.

                      -Lenny

                      Lenny Forziati
                      Vice President, Internet Products and Technical Services
                      Alpha Software Corporation

                      Comment


                      • #12
                        RE: Weight Conversion using a Dialog!

                        Lenny,
                        Already tried but leaning curve still only 1/2 inch from the floor!
                        Andy

                        Comment


                        • #13
                          RE: Weight Conversion using a Dialog!

                          Try this:

                          event_expanded = ""%code%
                          if a_dlg_button = "OK" then
                          ui_modeless_dlg_close(dialog_box_title)
                          elseif a_dlg_button = "rollup" then
                          ui_modeless_dlg_box(dialog_box_title,dlg_contracted,event_contracted)
                          elseif a_dlg_button = "feet"
                          m = 0.0283168 * ft
                          elseif a_dlg_button = "meters"
                          ft = 35.3146666 * m
                          end if
                          %code%


                          One thing to notice is that I removed the a_dlg_button="" lines. These are only needed for a modal dialog. You can leave them in the modal dialog, they won't hurt anything, but they aren't needed. What they do is prvent the modal dialog from closing.

                          -Lenny

                          Lenny Forziati
                          Vice President, Internet Products and Technical Services
                          Alpha Software Corporation

                          Comment


                          • #14
                            RE: Weight Conversion using a Dialog!

                            Lenny,
                            Thants done the trick - thanks for your assistance, I now know how to create this type of dialog, hip hip...

                            Here is the complete code just incase anyone else has been following the threads:

                            Regards
                            Andy

                            'Date Created: 27-Oct-2002 09:12:46 PM
                            'Last Updated: 27-Oct-2002 09:12:46 PM
                            'Created By : Lenny Forziati
                            'Updated By : Andy
                            dim ft as n = 0
                            dim m as n = 0
                            dim dialog_box_title as c
                            dialog_box_title = "Volume Conversion"
                            dlg_expanded = ""%dlg%
                            {can_exit=close}
                            {position=remember=test_dialog}
                            {region}
                            Cubic Feet: |{line=0,3}{sp=.75}[.16ft!feet];
                            Cubic Meters: |{sp=.75}[.16m!meters];
                            {line=2,0};
                            {endregion};
                            {region}
                            "12OK" "12Rollup";
                            {endregion}
                            %dlg%

                            dlg_contracted = ""%dlg%
                            {can_exit=close}
                            {position=remember=test_dialog}
                            Click Rolldown to enter data.;
                            {lf};
                            "12OK" "Rolldown";
                            %dlg%

                            event_expanded = ""%code%
                            if a_dlg_button = "OK" then
                            ui_modeless_dlg_close(dialog_box_title)
                            elseif a_dlg_button = "rollup" then
                            ui_modeless_dlg_box(dialog_box_title,dlg_contracted,event_contracted)
                            elseif a_dlg_button = "feet"
                            m = 0.0283168 * ft
                            elseif a_dlg_button = "meters"
                            ft = 35.3146666 * m
                            end if

                            if a_dlg_button = "rollup" then
                            ui_modeless_dlg_box(dialog_box_title,dlg_contracted,event_contracted)
                            end if
                            %code%

                            event_contracted = ""%code%
                            if a_dlg_button = "OK" then
                            ui_modeless_dlg_close(dialog_box_title)
                            end if

                            if a_dlg_button = "rolldown" then
                            ui_modeless_dlg_box(dialog_box_title,dlg_expanded,event_expanded)
                            end if
                            %code%

                            ui_modeless_dlg_box(dialog_box_title,dlg_expanded,event_expanded)

                            Comment

                            Working...
                            X