Data: Form from Form

Hi, I have a form (not a dream…). In this form (form A), there is a button that creates a text file with some data. Like: void clicked() { CommaIo myFile; County dpt; myFile = new CommaIo(“C:\test.txt”,“W”); myFile.write(dpt.CountyId); super(); } I would like the user choose the name and the site of the file. So I have created a new form (form B) with a text field (to put the name of the file) and a button to validate. This form is only used to get the file name because all the data that have to be writen in the file come from the datasource of the form A. Then, after cliking on the button of the form B, the name is sent to the form A. The problem is that the form B doesn’t sent the file name to the form A that has called the form B. The form B creates a new form A, so the code that writes into the file is never executed. How can the form B send the file name to the form A (that have called the form B) without create a new form A? Thanks, Vince

look at this topic. but, in your case, I think it would be much wiser to create a dialog instead of the form. you, know dialog dlg = new Dialog(“Label”); DialogField … … if ( { //here you can validate the control on the dialog. } I can write a complete example code if you need.

Use dialog is a good idea. It works. But I don’t know how to put a small icon (near the box where I put the name of the file) in order to browse the system disc and choose an existing file for example. When I made the form, I just had to put a string edit field and put the EDT : FilenameSave. Then the icon was generated automaticaly. If you know how to do… Vince ps: The topic begin with Hi Ivan, You are there once again for me … So your are the savior of a lot of people!! Thanks for helping bad developpers like me!!! [B)]

well, adding a field on a dialog is almost the same as it is with the form. After all, a dialog is also a form. after Dialog dlg = new Dialog(“Please choose filename to save file”); insert DialogField dlgField = dlg.addField(typeid(FileNameSave)); /* dlg.addFieldValue() this is if you want to init a value of the control */ then in code you can read the value of this field this way: dlgField.value()

Here is a job example: static void Job8(Args _args) { Dialog dlg = new Dialog(‘My Dlg’); DialogGroup dlgGroup = dlg.addGroup(‘Group Title’); DialogField dlgField = dlg.addField(typeid(FileNameSave)); ; if ( { box::info(dlgField.value()); } }

Thanks, It works very well. But in the system window of Windows (where you choose the path and the name of your file), the type field is inactive, and I can’t choose any format. When I used a form to do that, there were 2 choices: “.*” and “.txt”. I don’t know if it’s possible to configure this field in order to be able to put some formats. Vince

Don’t know how to specify filters for the FileNameSave type If I need to do it, I use winApi =) Here is a sample Job. The first parameter is the HWND of the window the dialog is attached to. static void Job10(Args _args) { str s; container conFilter = [“Excel Files(.xls)", ".xls”]; ; s = Winapi::getSaveFileName(0, conFilter, “”, //initialPath, “Specify SaveFile Name”, “”, “”); box::info(s); }

Your answer shows me the way. To put a filter on a FileNameSave type you just have to do: void clicked() { CommaIo myFile; container conFilter = ["Text File .txt ", “*.txt”]; str tmp = “”; DialogField df; Dialog dlg; dlg = new Dialog(“Save File”); dlg.filenameLookupFilter(conFilter); df = dlg.addField(typeid(FileNameSave)); if ( { tmp = df.value(); myFile = new CommaIo(tmp,“W”); if(!myFile) { throw error(“Erreur lors de la création du fichier”); } else { myFile.write(“hello world”); }… Thanks a lot for your invaluable advices!! Vince