IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Rock Ridge Farm (Larry) on January 09, 2006, 05:54:18 PM

Title: Reading variable length lines from a file.
Post by: Rock Ridge Farm (Larry) on January 09, 2006, 05:54:18 PM
I want to process an input file one line at a time. The lines are variable length.
Is there an easy way to get one line at a time from a file?
Title: Re: Reading variable length lines from a file.
Post by: Ionic Wind Support Team on January 09, 2006, 05:58:46 PM
Open the file and use ReadString.

See the "editor.src" example program for details.
Title: Re: Reading variable length lines from a file.
Post by: Rock Ridge Farm (Larry) on January 09, 2006, 06:00:56 PM
I was just looking at that - thanks
Title: Re: Reading variable length lines from a file.
Post by: Rock Ridge Farm (Larry) on January 09, 2006, 06:05:49 PM
Is there a place where I can get a list of commands and how
to use them? Are most of the commands the same as C++?

It has been 20+ years since I did any real C programming so
I am looking for a programers manual.
Title: Re: Reading variable length lines from a file.
Post by: Ionic Wind Support Team on January 09, 2006, 06:15:42 PM
The original alpha topics can help.  Look in the 'bin' directory of your installation and read all of the .inc files.

The commands for file i/o are relatively simple.  read/write and readstring, eof like in BASIC, etc.

Being an alpha version I haven't finished with the official docs yet.
Title: Re: Reading variable length lines from a file.
Post by: Parker on January 09, 2006, 06:50:38 PM
If you're more comfertable using the C library, you can import the declarations you want by using the "extern cdecl" statement:
extern cdecl int printf(...);
...


Note that variable arguments are handled differently than in C though. In Aurora when there is a ... you have to have at least one argument. C compilers don't require that.
Title: Re: Reading variable length lines from a file.
Post by: Rock Ridge Farm (Larry) on January 09, 2006, 07:00:18 PM
Can I declare an array of structures or is this a future feature?
The following fails:
struct pwfl {
   def sys as string;
   def uname as string;
   def pwflg as string;
   def uid as string;
   def gid as string;
   def gcos as string;
   def home as string;
   def shell as string;
} pwf[1000];
Title: Re: Reading variable length lines from a file.
Post by: Parker on January 09, 2006, 07:07:59 PM
That would be too confusing to C users where you commonly use "typedef struct" and that area is reserved for the typedef part.
typedef struct _pwfl {
   def sys as string;
   def uname as string;
   def pwflg as string;
   def uid as string;
   def gid as string;
   def gcos as string;
   def home as string;
   def shell as string;
} pwfl, *ppwfl;
Title: Re: Reading variable length lines from a file.
Post by: Ionic Wind Support Team on January 09, 2006, 07:33:02 PM
Yes you can declare an array of structures.  You can't do it in the same step as defining the structure as the array has to exist somewhere, either locally, globally or created with NEW

struct pwfl {
   def sys as string;
   def uname as string;
   def pwflg as string;
   def uid as string;
   def gid as string;
   def gcos as string;
   def home as string;
   def shell as string;
};

pwfl pwf[100];

Would work.


Title: Re: Reading variable length lines from a file.
Post by: Bruce Peaslee on January 09, 2006, 08:57:24 PM
Quote from: Ionic Wizard on January 09, 2006, 07:33:02 PM
Yes you can declare an array of structures.ÂÃ,  You can't do it in the same step as defining the structure as the array has to exist somewhere, either locally, globally or created with NEW

struct pwfl {
ÂÃ,  ÂÃ, def sys as string;
ÂÃ,  ÂÃ, def uname as string;
ÂÃ,  ÂÃ, def pwflg as string;
ÂÃ,  ÂÃ, def uid as string;
ÂÃ,  ÂÃ, def gid as string;
ÂÃ,  ÂÃ, def gcos as string;
ÂÃ,  ÂÃ, def home as string;
ÂÃ,  ÂÃ, def shell as string;
};

pwfl pwf[100];

Would work.


This is how I do it. In my project the main data is declared globally (eventually a no-no) until I get a better handleÂÃ,  :DÂÃ,  ÂÃ, on pointers and OOP.
Title: Re: Reading variable length lines from a file.
Post by: Rock Ridge Farm (Larry) on January 10, 2006, 06:17:03 AM
That worked - thanks.
Now for my next question.
The listview example is a stand alone program - can the listview be used as a child
window in a regular window program - sorry if these questions seem trivial.
Title: Re: Reading variable length lines from a file.
Post by: Bruce Peaslee on January 10, 2006, 08:31:17 AM
Yes. The listview examples have them as controls (child windows, actually) on a dialog window.
Title: Re: Reading variable length lines from a file.
Post by: Rock Ridge Farm (Larry) on January 10, 2006, 09:51:08 AM
How is a dialog window different than a regular window?
Advantages?
I wish to add buttons and input boxes to the window - is this doable in a dialog window
or should I use a regular window?
If you have an example of this it would help - already played with the listview example.
Title: Re: Reading variable length lines from a file.
Post by: Bruce Peaslee on January 10, 2006, 10:56:59 AM
I'm not the one to give a definitive answer on the differences in using a main window or a dialog, although it is my understanding the dialog boxes are meant for user input and give certain advantages.

Here is a simple example of using a dialog to get input:


const cmdD1OKÂÃ,  ÂÃ,  ÂÃ, = 1;
const cmdD1Cancel = 2;
const txtD1NameÂÃ,  ÂÃ, = 3;
const lblD1TitleÂÃ,  = 4;
const lblD1NameÂÃ,  ÂÃ, = 5;

string name;ÂÃ,  //global just for this example
name = "";

class dlg:cdialog
{
declare OnInitDialog(),int;
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
CControl *pEdit;
}

dlg::OnClose(),int
{
CloseDialog(false);
return true;
}

dlg::OnInitDialog(),int
{
/* Initialize any controls here */
CenterWindow();
return true;
}

dlg::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nID
{
case txtD1Name:
/* respond to edit notifications here */
case cmdD1OK:
if(nNotifyCode = 0)
{
pEdit = GetControl(txtD1Name);
name = pEdit->GetText();
CloseDialog(true);

}
case cmdD1Cancel:
if(nNotifyCode = 0) //button clicked
{
CloseDialog(false);
}
}
return true;
}
global sub main()
{
int result;
dlg d1;
d1.Create(0,0,300,202,0x80C80080,0,"Caption",0);
d1.AddControl(CTEDIT,ÂÃ,  "",ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, 133, 82,108,20,0x50810000,0,txtD1Name);
d1.AddControl(CTBUTTON,"OK",ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  63,142, 70,20,0x5001000B,0,cmdD1OK);
d1.AddControl(CTBUTTON,"Cancel",ÂÃ,  ÂÃ,  ÂÃ, 168,142, 70,20,0x5001000B,0,cmdD1Cancel);

d1.AddControl(CTSTATIC,"Test Dialog",115, 23, 70,20,0x5000010B,0,lblD1Title);
d1.AddControl(CTSTATIC,"Name",ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  59, 82, 70,20,0x5000010B,0,lblD1Name);

result = d1.DoModal();
if (result=true)
{
MessageBox(0,"Name = " + name,"",0);
}
else
{
MessageBox(0,"Operation cancelled","",0);
}
return 0;
}
Title: Re: Reading variable length lines from a file.
Post by: Zen on January 10, 2006, 11:05:47 AM
As for when to use windows and dialogs... This is microsoft say

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/aboutdialogboxes.asp
Title: Re: Reading variable length lines from a file.
Post by: Bruce Peaslee on January 10, 2006, 11:11:58 AM
Quote from: Lewis on January 10, 2006, 11:05:47 AM
As for when to use windows and dialogs... This is microsoft say

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/aboutdialogboxes.asp

WordyÂÃ,  ;)ÂÃ,  but good information. Notice how Aurora makes this a whole lot easier.
Title: Re: Reading variable length lines from a file.
Post by: Rock Ridge Farm (Larry) on January 10, 2006, 12:13:19 PM
One more question.
Can a dialog box have menus?
Title: Re: Reading variable length lines from a file.
Post by: Ionic Wind Support Team on January 10, 2006, 12:43:49 PM
Yes.  Set up the menu in OnInitDialog.
Title: Re: Reading variable length lines from a file.
Post by: Rock Ridge Farm (Larry) on January 10, 2006, 05:25:42 PM
Since I have taken this discussion so far off topic - I started a new topic about menus.