Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning and accepting values from a FoxPro.exe
Message
De
14/06/1999 13:40:02
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00229033
Message ID:
00229564
Vues:
16
>>>When communicating with a web page, I am unable to get the values from a GET or POST action method. In C, if you use getenv, you can retrieve QUERY_STRING, and other form variables. You can pass parameters from a web page directly to a C program. You can also send a printf directly to the standard output, these string outputs will be directed to a new web page.
>>>
>>>Why is FoxPro unable to see these same parameters? Is there a way to send text directly like C does?
>>>
>>>Dan
>>
>>I am unclear on how you are "communicating with a web page"... Can you give more details?
>
>
>Using C, you could use the "POST" action form method you can call a program directly.
>
>FORM METHOD="POST" ACTION="http://dcummings/cStuff/POST_QUERY.exe"

You are actually posting these variables to the web server. The server (IIS, whatever) is then responsible for calling the exe in the URL. If the


>
>Below is the c program that is called.
>The getenv is used to retrieve information from the form, such as the CONTENT_LENGTH and the REQUEST_METHOD.
>
>The printf is printing to what is called the stdout ( standard output ). In this case it prints directly to a new web page.
>
>I was looking for a way to do that directly with FoxPro. Rick Strahl in WestWind, uses a DLL. I believe it's written in C. It processes the information and creates an ascii file. Meanwhile, a foxpro app, running in the background has a timer which keeps checking for the existence of a specific file. Once the file is found, the FoxPro app reads in the information and generates a new page.
>
>I was hoping there was a way to bypass this middle step using the DLL.
>
>Maybe communicating with the web page was not the right wording.
>
>
>Some of the code had to be altered to prevent the HTML display.
>
>
>#include <stdio.h>
>#ifndef NO_STDLIB_H
>#include <stdlib.h>
>#else
>
>char *getenv();
>
>#endif
>#include <string.h>
>
>#define MAX_ENTRIES 10000
>
>typedef struct {
>    char *name;
>    char *val;
>} entry;
>
>char *makeword(char *line, char stop);
>char *fmakeword(FILE *f, char stop, int *len);
>char x2c(char *what);
>void unescape_url(char *url);
>void plustospace(char *str);
>
>
>void main(int argc, char *argv[]) {
>    entry entries[MAX_ENTRIES];
>    register int x,m=0;
>    int cl;
>
>    printf("Content-type: text/html%c%c",10,10);
>
>    if(strcmp(getenv('REQUEST_METHOD'),'POST')) {
>        printf('This script should be referenced with a METHOD of POST.\n');
>        printf('If you don't understand this, see this ');
>        printf('<A HREF=\'http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/Docs/fill-out-forms/overview.html\'>forms overview</A>.%c',10);
>        exit(1);
>    }
>    if(strcmp(getenv('CONTENT_TYPE'),'application/x-www-form-urlencoded')) {
>        printf('This script can only be used to decode form results. \n');
>        exit(1);
>    }
>    cl = atoi(getenv('CONTENT_LENGTH'));
>
>    for(x=0;cl && (!feof(stdin));x++) {
>        m=x;
>        entries(x).val = fmakeword(stdin,'&',&cl);
>        plustospace(entries(x).val);
>        unescape_url(entries(x).val);
>        entries(x).name = makeword(entries(x).val,'=');
>    }
>    printf('<' + 'H1>Query Results<' + '/H1>');
>    printf('You submitted the following name/value pairs:<' + 'p>' + '%c',10);
>    printf('<' + 'ul>' + '%c',10);
>
>    for(x=0; x <= m; x++)
>        printf('<li' + '>' + '<code>%s = %s</code>%c',entries(x).name,
>               entries(x).val,10);
>
>    printf('<' + '/ul>' + '%c',10);
>
>}
>
Erik Moore
Clientelligence
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform