I've been stuck in this for hours now. I'm trying to use the string 'from_file' in the function add() (within another class), but I'm not sure how to go about it.
Right now your from_file string is a local variable of a function, so unless you return it from the function or change it to a member of your Simple_window class you won't have access to it outside of the open() function.
Without understanding the relationship between the two classes, it is hard to advise on how best to achieve what you're trying to do (e.g. are the classes part of an inheritance tree, or a composition, or completely separate).
My Simple_Window class is being used to display some input boxes, one of which provides the option to enter a file name. By clicking open, a separate window (a Picture_window) displays the image given by the user. What I hope to accomplish with the second piece of code is to place the name of the picture file (the input in the Simple_window) into text files corresponding to the picture's tags (which the user assigns through a Add Tags box in the Picture_Window. If you need some code and/or pictures to help visualize it...
OK, well since you are creating a Picture_window class in your call to open, you could add a function like SetFile() to Picture_window which would set a datamember in the class. It's not extensible, but it will work for that case.
1 2 3 4 5 6 7 8 9 10
if(from_file != "")
{
Try_again(from_file);
Image mypic(Point(50,50), from_file);
Picture_window pwin(Point(100,100), 600, 400, "Picture Window");
pwin.SetFile(from_file); // Set the file name here
pwin.attach(mypic);
Fl::redraw();
pwin.wait_for_button();
}