how do i call a C++ program from a webpage??

acejj26

Senior member
Dec 15, 1999
886
0
0
EDIT: my standalone program runs perfectly now...now i need a way for a link on a webpage, when clicked, to call a C++ program i wrote. any suggestions?
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
The application will be simple.

Your program must know where the text file is stored.
Either a fixed location or passed in as a start parameter.


Logic:

Open the file
Read in a line of text.
Parse the text using tabs as a token delimiter
Build your array as a structure/class using a linked list of pointers.
Each time you read a line, allocate a new storage area.
Link this storage area to the tail of the previous
Strip out each field and put field into the approiate variable of the storage area.
Get new line of text

Array now built

loop through the array, formatting and sending output to the printer.

1-2 hour development effort.

Good Luck
 

acejj26

Senior member
Dec 15, 1999
886
0
0
ok, the logic part seems simple enough

but the real task is the implementation. i'll use parallel vectors when reading in the file. however, i'm having trouble reading in the file and storing the information in the parallel vectors. any help with this??
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Not knowing which platform you are developing for I will try to clue you in using C psuedo code

typedef array structure
string array_field[n];
array_structure* next;
}
array_structure base_array;
array_structure *array, *last_array = &base_array;
line = 0
hFile = fopen (filename,"rt");
while (!EOF)
fgets( string, 255, hFile ); // maximum of 255 characters per line read in
token = 0;
array = new array_structure;
last_array.next = array;
strToken = string;

while (parsing condition == true)
field = strtok( strToken, <tab> ) ;
array.array_field[token] = field;




 

acejj26

Senior member
Dec 15, 1999
886
0
0
i'm writing for Windows platform using Microsoft Visual C++ 6.0

i'd really appreciate some more insight as to the actual coding specifics...i know that i can learn everything in time, but getting me going with some basic details might help me jog my memory
 

manly

Lifer
Jan 25, 2000
12,263
3,172
136
EagleKeeper gave plenty of specific advice in his C pseudocode.

I'm not sure how you plan on binding the HTML (user interaction) to the native-app though. There are ways, but I'm not aware of any good & simple ones.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Thanks manly

acejj26
Any more guidance and the app will be written for you.
If you are not a programmer, then I can understand why you are having problems.
You should be able to build this within a days time max if you have programming under your belt with C/C++.
With just academic training and 2 years rust, it may be hard, but you need to get in shape.
 

TAsunder

Senior member
Oct 6, 2000
287
0
0
Maybe I'm not understanding... will this C++ program be installed on the user's computer already? Or are you planning on running a C++ program that is not installed on the user's machine with the click of a button? It's going to take more than a click of a button. The user would have to agree to run the program, and download it onto their computer, etc.

Everything you've mentioned so far except the printing part could be done with simple javascript... why does it need to be C++?
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0


<< the user clicks on another button that kicks off my C++ program on the user's machine >>



TAsunder

Impression is that he wants the program to reside on the user machine.

Based on what you are describing with a Java script, could the script output to a user selected printer?
 

acejj26

Senior member
Dec 15, 1999
886
0
0
eaglekeeper,

i appreciate all the help you have provided. i know that i need to do some work on my own.

TAsunder,

i need this program to run on the user's machine, but i would be open to suggestions on how it could be run from a server to print to a label printer at a user's desk....i don't know enough about printing to know if this is possible

if anyone else can add any insight here, i'd really appreciate it

eaglekeeper, tasunder, i appreciate your guys' help too!

 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
If the printer is shared and visible from the server, any program can output to the printer just as if it was a local printer on the host machine.
 

acejj26

Senior member
Dec 15, 1999
886
0
0
ok, guys, the standalone program is built and runs exactly how i want it

however, now i need a way to kick off the program from a link on a webpage. does anyone know how to do that?? my boss threw out a buzzword (ActiveX), although he had no clue what he was talking about (maybe you can use ActiveX, but he didn't know how to do it...he just heard the word somewhere and decided to throw it out there). i'll know where the file will be stored and what it's name will be. i'll also know where the program will reside. i just need a way for a webpage to kick off my program.

as always, any and all recommendations are appreciated :)
 

Jackhamr60504

Member
Nov 12, 2001
96
0
0
I just started reading this thread. It looks as if the program is for a lan to print labels. Why not just put the executable on a shared drive on the network? Something like \\server\Public\program.exe. Then, just call that file from the website.

Would this work?
 

acejj26

Senior member
Dec 15, 1999
886
0
0
jackhamr.....that's the issue though....how do i call a program from a webpage?? i can't find any resources that show me how to do it. if you know how, that'd be great. thinking about it, i don't think i need the file or the program on the user's machine. i just need to call the program from the webpage. any other help??
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
Originally posted by: acejj26
jackhamr.....that's the issue though....how do i call a program from a webpage?? i can't find any resources that show me how to do it. if you know how, that'd be great. thinking about it, i don't think i need the file or the program on the user's machine. i just need to call the program from the webpage. any other help??

HTML pages are not allowed to access the user's hard-drive. It would be a security violation. Of course, there are ways to do it in IE, but those ways are known as hacks or exploits ;) As mentioned earlier, what you're trying to do is best done through an Application, not a web-page. If you are limited to a HTML page, then look into ActiveX - which will only work on Internet Explorer, not other browser.
 

acejj26

Senior member
Dec 15, 1999
886
0
0
ok, here's what i'm gonna do...see if it sounds plausible

when the user tells the ASP what lines he wants to print, the file is created and stored on the server. then the page redirects the user to the same page, only with a flag set that allows the link to be visible to run my program that is stored on the server. the program then reads in the file that is stored on the server and sends the output to the printer attached to the user's computer.
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
Assuming that you are deploying this over a LAN, I think that you are making this more complicated than it should be.

Simply make a link to the executable and put instructions to the users on how to respond to the security warning messages. If the app runs over a LAN connection, IE will be more lineant with security enforcements.

If I am not understanding your situation properly, it might help if you describe the business problem in a bit more detail. I am a bit confused about what you are trying to get at.
 

acejj26

Senior member
Dec 15, 1999
886
0
0
joohang,

initially, what i wanted was to write a C++ program that was stored locally on the user's machine. from a webpage, the user would be able to select what line items he/she wanted to be printed on a label printer, and the file with the information would be stored as a text file. then, the C++ program would read in this text file and print as many labels as was specified by the text file.

what i wanted was a way for a webpage to call this program that was stored on the user's machine. i had no clue on how to do that. but it dawned on me that if i kept the program on my webserver and i stored the file in a fixed location so that the program would always know where to read it, i wouldn't have to worry about deploying the program or installing it or worrying about user error.

so, what i'm doing now is having the user submit to my webpage what labels he wants to print. the program then uses FSO to create a file on the webserver. the page then redirects to itself passing a flag that when read by the program will show a link to my executable (like you said). then when clicked, the user gets the option of running it or saving it. we will tell him to run it. then they can hit print on the form there and the program reads in the file the user just created and the user's label printer prints out the labels.

it should work. i haven't finished everything yet, but i don't see how it can't work. i hope that cleared everything up.