May 04, 2024, 05:16:02 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Reading variable length lines from a file.

Started by Rock Ridge Farm (Larry), January 09, 2006, 05:54:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rock Ridge Farm (Larry)

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?

Ionic Wind Support Team

Open the file and use ReadString.

See the "editor.src" example program for details.
Ionic Wind Support Team

Rock Ridge Farm (Larry)


Rock Ridge Farm (Larry)

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.

Ionic Wind Support Team

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.
Ionic Wind Support Team

Parker

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.

Rock Ridge Farm (Larry)

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];

Parker

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;

Ionic Wind Support Team

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.


Ionic Wind Support Team

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Rock Ridge Farm (Larry)

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.

Bruce Peaslee

Yes. The listview examples have them as controls (child windows, actually) on a dialog window.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Rock Ridge Farm (Larry)

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.

Bruce Peaslee

January 10, 2006, 10:56:59 AM #13 Last Edit: February 25, 2006, 11:21:02 AM by peaslee
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;
}
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Zen


Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Rock Ridge Farm (Larry)

One more question.
Can a dialog box have menus?

Ionic Wind Support Team

Ionic Wind Support Team

Rock Ridge Farm (Larry)

Since I have taken this discussion so far off topic - I started a new topic about menus.