Hi,
I am trying to write info to a txt file.
All I am getting in the txt file is message.
Code:
// include files nedeed by our code.
#include <plugin.h>
#include <stdio.h>
#include <lib/gui/ewindow.h>
#include <lib/gui/elabel.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/emessage.h>
#include <lib/gui/textinput.h>
// The Class declaration of our Main Window
class eBibleMainWindow: public eWindow
{
// the label to show the text
eLabel *label;
// the textinput
eTextInputField *mytext;
eTextInputField *mytext1;
eTextInputField *mytext2;
eTextInputField *mytext3;
eTextInputField *mytext4;
eTextInputField *mytext5;
eTextInputField *mytext6;
eTextInputField *mytext7;
// function to execute when button is pushed
void message1();
public:
// the constructor.
eBibleMainWindow();
// the destructor.
~eBibleMainWindow();
};
// The plugin entry point, Here start the code execution
extern "C" int plugin_exec( PluginParam *par )
{
// our demo dialog instance.
eBibleMainWindow dlg;
// show the dialog...
dlg.show();
// give control to dialog.. (the dialog is modal!)
int result=dlg.exec();
// and after it, hide it again.
dlg.hide();
return result;
}
eBibleMainWindow::eBibleMainWindow(): eWindow(1)
{
// move our dialog to 100.100...
cmove(ePoint(100, 100));
// ...and give x and y dimensions.
cresize(eSize(550, 376));
// set a title.
setText("!!EDITOR!!");
// create a label to show a text.
label=new eLabel(this);
// give a position
label->move(ePoint(20, 50));
// set the label dimensions
label->resize(eSize(400, 100));
// set the label text
label->setText("Enter Here.");
// create textinput
mytext=new eTextInputField(this);
// give position
mytext->move(ePoint(20, 100));
// give size
mytext->resize(eSize(25, 40));
// set max number of characters
mytext->setMaxChars(1);
//mytext->setUseableChars("1234567890");
//mytext->setText(codeentry);
// show a frame decoration
mytext->loadDeco();
// create buttons and set properties
eButton * ok = new eButton(this);
ok->setText("Update Key File");
ok->move(ePoint((clientrect.width() - 60)/4, clientrect.height() - 60));
ok->resize(eSize(300, 40));
ok->setShortcut("green");
ok->setShortcutPixmap("green");
ok->loadDeco();
// function to call when button is pushed
CONNECT(ok->selected, eBibleMainWindow::message1);
//set focus to textinput
setFocus(mytext);
}
void eBibleMainWindow::message1()
{
// declare variable we will use in this function
eString message, message2;
// assign to message2 the textinput content
message2 = mytext->getText();
// compose message concatenating strings
message = message2;
// create messagebox (two buttons yes/no)
eMessageBox box((message), "Question", eMessageBox::btYes|eMessageBox::btNo|eMessageBox::iconQuestion, eMessageBox::btYes);
// show it
box.show();
// execute code and store in the variable button the result (button pressed)
int button = box.exec();
// hide it after execution
box.hide();
// exit if button yes was pushed.
if (button == eMessageBox::btYes)
{
FILE *fp;
fp = fopen ("/var/keys/1.txt", "w");
if (fp)
{
fprintf (fp, "message");
fclose (fp);
}
}
}
eBibleMainWindow::~eBibleMainWindow()
{
// we have to do almost nothing here. all widgets are automatically removed
// since they are child of us. the eWidget-destructor will to this for us.
}