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 and HTML

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

    Xbasic and HTML

    I have the following Xbasic dialog box:
    'Create an XDialog dialog box to prompt for parameters.
    DIM SHARED varC_result as C
    DIM vc_graph as p
    DIM vc_graph.html as c
    DIM vc_graph.css as c
    DIM vc_graph.linkedFiles as c
    DIM vc_graph.events as c

    vc_name = "Andre the Giant"
    vc_graph.html = <<%html%
    <a5:bindings>
    </a5:bindings>

    <a5:propertyExpressions>
    </a5:propertyExpressions>

    <html>
    <head>
    <script language="JavaScript" src="c:\alpha_data\Graph.js"></script>
    </head>
    <body style="font-family: Arial;">
    <table align="center">
    <tr>
    <td width="5%"></td>
    <td id="here" align="center"></td>
    <td valign="top" width="5%"></td>
    </tr>
    </table>
    </body>
    </html>
    <script language="JavaScript">
    var bg = new Graph(9);
    var name = "Andre the Giant";

    bg.parent = document.getElementById('here');
    bg.title = name;
    bg.xCaption = 'dates';
    bg.yCaption = 'Weight<br>(lbs.)';

    bg.xValues[0] = [210,'1/14/09'];
    bg.xValues[1] = [195,'1/28/09'];
    bg.xValues[2] = [170,'2/4/09'];
    bg.xValues[3] = [175,'2/11/09'];
    bg.xValues[4] = [182,'2/18/09'];
    bg.xValues[5] = [186,'2/25/09'];
    bg.xValues[6] = [189,'3/4/09'];
    bg.xValues[7] = [195,'3/11/09'];
    bg.xValues[8] = [193,'3/18/09'];
    //bg.xValues[9] = [193,'3/25/09'];

    bg.showLine = true;
    bg.showBar = false;
    bg.draw();
    </script>
    %html%
    vc_graph.css = <<%css%

    %css%
    vc_graph.linkedFiles = <<%str%

    %str%
    vc_graph.events = <<%code%

    %code%
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Alpha Five",<<%dlg%
    {region}
    | {HTMLForm=150,40vc_graph};
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%)
    What I have done above creates the dialog box pictured here below.
    What I would like to do is dynamically change the dates and weights ( bg.xValues[0] - bf.xValues[9] )with values in a table. I know how to create an array with the dates and weights I want, I just don't know how to change the xbasic so that the data gets into the script for each different patient.
    Thanks in advance.
    Last edited by Jay Talbott; 06-17-2009, 10:28 PM.
    Jay Talbott
    Lexington, KY


    #2
    Re: Xbasic and HTML

    Try the desktop forum, this is the app server forum!

    Comment


      #3
      Re: Xbasic and HTML

      Thanks.
      I was thinking the Javascript and HTML issues would make this the logical place to get an answer, but I will post it on the desktop side.

      Jay
      Jay Talbott
      Lexington, KY

      Comment


        #4
        Re: Xbasic and HTML

        Originally posted by Jay Talbott View Post
        Thanks.
        I was thinking the Javascript and HTML issues would make this the logical place to get an answer, but I will post it on the desktop side.

        Jay
        Xdialogs are desktop-only so people experienced in Web/WAS development won't necessarily be familiar with what you were trying to do.

        Comment


          #5
          Re: Xbasic and HTML

          Not to be obstinate, but the real question is a Javascript question. I can handle all of the Xdialog issues.
          The real question here is:
          How can I get the data dynamically loaded into the Javascript from the table?

          Thanks.
          Jay
          Jay Talbott
          Lexington, KY

          Comment


            #6
            Re: Xbasic and HTML

            Jay, what happens if you store the string
            Code:
            [210,'1/14/09']
            in a variable, and then pass that variable to
            Code:
            bg.xValues[0]

            Comment


              #7
              Re: Xbasic and HTML

              Tom,
              Thanks for the idea. What I am having a problem with is trying to populate the variable from Alpha (outside the javascript) and then getting the javascript to read that variable.
              I have tried the following:
              dim vc_test as c
              vc_test = "[213,'01/17/09']"
              .
              .
              .
              <script language="JavaScript">
              var bg = new Graph(9);
              var name = "Andre the Giant";

              bg.parent = document.getElementById('here');
              bg.title = name;
              bg.xCaption = 'dates';
              bg.yCaption = 'Weight<br>(lbs.)';

              bg.xValues[0] = vc_test;
              I get the message: vc_test is undefined.
              If I add var vc_test within the javascript, I get the error: vc_test is null
              Jay
              Jay Talbott
              Lexington, KY

              Comment


                #8
                Re: Xbasic and HTML

                I feared as much. Sorry it wasn't that easy. -- tom

                Comment


                  #9
                  Re: Xbasic and HTML

                  Since there isn't enough there to run your xdialog on my machine, can you clarify what you mean by "dynamically"? Does that mean "each time I start the xdialog" or does it mean "once I've started the xdialog I want to be able to select a different name and then automatically rebuild the chart without restarting the xdialog"?

                  Comment


                    #10
                    Re: Xbasic and HTML

                    Cal,
                    What I initially wanted to do was to be able to put a button to run this xdialog box on each patient record, and have the graph be created (dynamically) for each customer.
                    I am finally successful.
                    I used the file.append() command to add the var to the end of the graph.js file (which is what you are missing to run this xdialog box on your computer).

                    Here is the command line I have used to add the line to the graph.js file:

                    file.append("c:\alpha_data\graph.js", crlf()+"var data_1 = [234, 'Jan 17, 1958']" )

                    I then changed the line:
                    bg.xValues[0] = [210,'1/14/09'];

                    to
                    bg.xValues[0] = data_1;

                    This was just a test. Now I will have to add all of the lines, but that can easily be done with string (text) commands using variables that pick up the values for each patient.
                    If you want the graph.js file, it is attached as graph.txt.
                    Just rename the file to graph.js when you download it.
                    Jay
                    Jay Talbott
                    Lexington, KY

                    Comment


                      #11
                      Re: Xbasic and HTML

                      One last issue (hopefully the last one):

                      in the array of bg.xValues[0] - bg.xValues[9] in the example above, the assumption is that there are 10 records for the graph. In some cases, the new patients won't have 10 months of data.

                      If I make some of the elements empty, like this:
                      var data_9 = []
                      var data_10 = []
                      var data_11 = []
                      var data_12 = []

                      the graph looks terrible (see attached image below).
                      How can I dynamically resize that array?
                      Thanks.
                      Jay
                      Jay Talbott
                      Lexington, KY

                      Comment


                        #12
                        Re: Xbasic and HTML

                        Here is a slightly different approach.
                        The variable vc_graph.html is just made up of text. So you can pre process/create the section that contains the bg.xValues section and then concatenate that into the rest of the variable's text. This will eliminate the need for writing to the graph.js file.

                        I have not tested this as I am writing this from a none Alphafive enabled computer, (I know who ever heard of such a thing :)), but I am pretty sure I have the syntax correct.

                        Code:
                                                     'Create an XDialog dialog box to prompt for parameters.
                        DIM SHARED varC_result as C
                        DIM vc_graph as p
                        DIM vc_graph.html as c
                        DIM vc_graph.css as c
                        DIM vc_graph.linkedFiles as c
                        DIM vc_graph.events as c
                        
                        [COLOR=DarkGreen] Dim graph_xdata as C[/COLOR]
                        [COLOR=RoyalBlue]'Use what ever you currently do to get the data values into a variable as a crlf delimited list. 
                        'Below the values are hard coded for this example[/COLOR]
                        [COLOR=DarkGreen] graph_xdata = <<%txt%
                        [210,'1/14/09']
                        [195,'1/28/09']
                        [170,'2/4/09']
                        [175,'2/11/09']
                        [182,'2/18/09']
                        [186,'2/25/09']
                        [189,'3/4/09']
                        [195,'3/11/09']
                        [193,'3/18/09']
                        [193,'3/25/09']
                        %txt%[/COLOR]
                        [COLOR=RoyalBlue]'The *for_each() function acts on each line in the variable.
                        [/COLOR][COLOR=RoyalBlue] 'The number of array elements are limited to the number of data values present in the variable[/COLOR]
                        [COLOR=RoyalBlue]'the *Counter() function below provides the numeric value for the array.
                        'We subtract 1 to make the array start with zero. 
                        [/COLOR]
                        [COLOR=DarkGreen] graph_xdata = *for_each(ln,"bg.xValues["+*Counter()-1+"] = " + ln + ";",graph_xdata)[/COLOR]
                        
                        
                        vc_name = "Andre the Giant"
                        vc_graph.html = <<%html%
                        <a5:bindings>
                        </a5:bindings>
                        
                        <a5:propertyExpressions>
                        </a5:propertyExpressions>
                        
                        <html>
                        <head>
                        <script language="JavaScript" src="c:\alpha_data\Graph.js"></script>
                        </head>
                        <body style="font-family: Arial;">
                        <table align="center">
                        <tr>
                          <td width="5%"></td>
                          <td id="here" align="center"></td>
                          <td valign="top" width="5%"></td>
                         </tr> 
                        </table>
                        </body>
                        </html>
                        <script language="JavaScript">
                        var bg = new Graph(9);
                        var name = "Andre the Giant";
                        
                        bg.parent = document.getElementById('here');
                        bg.title = name;
                        bg.xCaption = 'dates';
                        bg.yCaption = 'Weight<br>(lbs.)';
                        [COLOR=RoyalBlue]'Here we stop the html string definition. Concatenate the data variable.
                        'Then concatenate the remainder of the html string by restarting with <<%html%[/COLOR]
                        [COLOR=DarkGreen]%html%[/COLOR] [COLOR=DarkGreen]+ graph_xdata + <<%html%[/COLOR]
                        
                        bg.showLine = true;
                        bg.showBar = false;
                        bg.draw();
                        </script>
                        %html%
                        vc_graph.css = <<%css%
                        
                        %css%
                        vc_graph.linkedFiles = <<%str%
                        
                        %str%
                        vc_graph.events = <<%code%
                        
                        %code%
                        ok_button_label = "&OK"
                        cancel_button_label = "&Cancel"
                        varC_result = ui_dlg_box("Alpha Five",<<%dlg%
                        {region}
                        | {HTMLForm=150,40vc_graph};
                        {endregion};
                        {line=1,0};
                        {region}
                        <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                        {endregion};
                        %dlg%)
                        Tim Kiebert
                        Eagle Creek Citrus
                        A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                        Comment


                          #13
                          Re: Xbasic and HTML

                          I found a mistake in the *for_each syntax. The *Counter()-1 needs to be in parenthesis.

                          Code:
                          [COLOR=DarkGreen] graph_xdata = *for_each(ln,"bg.xValues[" +[B][COLOR=Red] ([/COLOR][/B]*Counter()-1[B][COLOR=Red])[/COLOR][/B] + "] = " + ln + ";",graph_xdata)[/COLOR]
                          Tim Kiebert
                          Eagle Creek Citrus
                          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                          Comment


                            #14
                            Re: Xbasic and HTML

                            Thanks a million Tim. I want to be just like you when I grow up. OK, maybe it's too late for that. But anyway, thanks again. I'll let you know how I make out.
                            Jay
                            Jay Talbott
                            Lexington, KY

                            Comment


                              #15
                              Re: Xbasic and HTML

                              Jay,
                              You can also directly write to the HTML window using the (admittedly confusing) techniques outlined in "Xdialog, Javascript and HTML".
                              I don't have your css files, so my graph doesn't look pretty. Here's code, though, for changing the graph:

                              Code:
                              html = <<%html%
                              <html>
                              <head>
                              
                              <object classid="clsid:EE3218B4-5E36-4435-93D6-FB563D7BAD16" id="A5CONTEXT" width="0" height="0">
                              <param name="listen" value="{CTXEVALNAME}">
                              </object>
                              <script type="text/Javascript" for="A5CONTEXT" event="Event(event_data)" >
                              <!--
                              callFromXbasic(event_data);
                              -->
                              </script>
                              
                              <script language="Javascript">
                              // grab the ContextEval object
                              oj = document.getElementById("A5CONTEXT").object
                              function callXbasic(codetorun){
                              js = oj.eval("{CTXEVALNAME}",codetorun);
                              if(typeof(js) == 'string' && js!=''){
                              eval(js);
                              }
                              }
                              function callFromXbasic(codetorun){
                              if(typeof(codetorun) == 'string' && codetorun!=''){
                              eval(codetorun);
                              }
                              }
                               </script>
                              
                              <script language="Javascript" src="c:\graph.js"></script>
                              
                              </head>
                              
                              <body style="font-family: Arial;">
                              <table align="center">
                              <tr>
                              <td width="5%"></td>
                              <td id="here" align="center"></td>
                              <td valign="top" width="5%"></td>
                              </tr>
                              </table>
                              </body>
                              
                              <script language="javascript">
                              var bg = new Graph(9);
                              var name = "Andre the Giant";
                              
                              bg.parent = document.body;
                              bg.title = name;
                              bg.xCaption = 'dates';
                              bg.yCaption = 'Weight<br>(lbs.)';
                              
                              bg.xValues[0] = [210,'1/14/09'];
                              bg.xValues[1] = [195,'1/28/09'];
                              bg.xValues[2] = [170,'2/4/09'];
                              bg.xValues[3] = [175,'2/11/09'];
                              bg.xValues[4] = [182,'2/18/09'];
                              bg.xValues[5] = [186,'2/25/09'];
                              bg.xValues[6] = [189,'3/4/09'];
                              bg.xValues[7] = [195,'3/11/09'];
                              bg.xValues[8] = [193,'3/18/09'];
                              
                              bg.showLine = true;
                              bg.showBar = false;
                              bg.draw();    
                              </script>
                              </html>
                              %html%
                              
                              dim shared XbasicCtxName as c="JSGraph"
                              dim XbasicCtx as p
                              XbasicCtx=ole.create("a5contexteval.contexteval")
                              XbasicCtx.Attach(*Xbasic_eval_context_attach())
                              xbasic_eval_context_add(XbasicCtxName)
                              html=ole.HTMLobject_Remap(html)
                              
                              html=stritran(html,"{CTXEVALNAME}",XbasicCtxName)
                              file.from_string(file.temp_path_get()+"my.html",html)
                              
                              dim browser as p
                              dim browser.object as p
                              dim browser.class as c="shell.explorer.2"
                              
                              ok_button_label = "&OK"
                              cancel_button_label = "&Cancel"
                              ui_dlg_box("Alpha Five",<<%dlg%
                              {startup=init}
                              {region}
                              {activeX=120,30browser};
                              {endregion};
                              {line=1,0};
                              {region}
                              <*15=ok_button_label!OK> <Jay!jay> <15=cancel_button_label!CANCEL>
                              {endregion};
                              %dlg%,<<%code%
                              if a_dlg_button="init" then
                                  a_dlg_button=""
                              	 browser.object.navigate(file.temp_path_get()+"my.html")
                              end if
                              if a_dlg_button="jay" then
                              	a_dlg_button=""
                                  jsCode=<<%js%
                              var bg = new Graph(6);
                              var name = "Jay the Great";
                              
                              bg.parent = document.body;
                              bg.title = name;
                              bg.xCaption = 'dates';
                              bg.yCaption = 'Weight<br>(lbs.)';
                              
                              bg.xValues[0] = [170,'1/5/09'];
                              bg.xValues[1] = [172,'1/28/09'];
                              bg.xValues[2] = [174,'2/5/09'];
                              bg.xValues[3] = [175,'2/11/09'];
                              bg.xValues[4] = [182,'2/18/09'];
                              bg.xValues[5] = [186,'2/25/09'];
                              bg.showLine = true;
                              bg.showBar = false;
                              bg.draw();    
                              %js%
                              xbasic_eval_context_send(XbasicCtxName,jsCode)
                              end if
                              %code%)
                              I also had to make one modification to the graph.js javascript. I commented out the line
                              bg.parent.appendChild(d.getElementById('wrapper'));
                              which appears right after the comment,
                              //Stablish parenthood

                              This line causes a permission violation when it's run a second time, and it doesn't seem to matter if it's commented out.

                              - Peter

                              Comment

                              Working...
                              X