Page 1 of 2

FOPEN/READSTRING Oddities

PostPosted: Sep 14, 2004 @ 11:51pm
by sponge

PostPosted: Sep 15, 2004 @ 12:03am
by kornalius

PostPosted: Sep 15, 2004 @ 12:28am
by sponge
I'm going to be parsing a config file in this format:

[Setup]
SetupVersion = "1.3D"

[Engine Setup]
UsingGapi = 1
Platform_Timer_HZ = 100
LandscapeMode = 0
CacheMemory = 2600
ShowFPS = 1
TickRate = 100
TicksPerFrame = 26
ScanCodeMapping = 1

The way I was thinking about handling it was just for each line, use a regex and set variables with the name of what's to the left, with the value of what's to the right, and then put the values in a form.

$10 says I'm doing it in a horrible messy and overly complex way ;)

PostPosted: Sep 15, 2004 @ 12:45am
by kornalius
You could also do the following:

s$ = loadstr("\\MyDocuments\\config.txt");
lines$ = strtolist(s$, #13#10);
ForEach(lines$)
s$ = lines$;
if (s$[0] == '[')
// do something here
else if (s$ <> "")
f$ = strtolist(s$, "=");
// do something here
end;
end;

That is one way but I think the best way is to use ini file routines.

I will add these routines to a library file tomorrow and incorporate it into the next pre-release, I will give you an example also.

PostPosted: Sep 15, 2004 @ 1:23am
by sponge
Yet another question (geez at this rate I'll probably have no code on my own by the end of this :P)

How do I use variables as the text in an editbox? In eVB I'd set it just with a form1.editbox.label == varible, do I do something similar in PPL?

PostPosted: Sep 15, 2004 @ 1:37am
by kornalius
In PPL you work with an HWND (int) handle. Every control and windows have their own unique handle. When PPL (Visual Form Builder) creates it's windows or controls it uses the same handle.

The handle variable name is always the same as the name you give your control in the visual form builder + an $ at the end. Ex: If you have a label named MyLabel in the Visual Form Builder you will set it's caption with the following line of code:

SetWindowText(MyLabel$, "Text");
or
SetWindowText(MyLabel$, Variable$);

SetWindowText works for a lot of controls and the window's title bar as well.

Check http://www.msdn.com for technical reference. PPL uses pretty much the same functions for API as C would.

PostPosted: Sep 15, 2004 @ 1:40am
by sponge
Heh, answerred my next question too. Didn't think MSDN would be applicable, but then again this is the closest I've gotten to any C-like language. Thanks again!

PostPosted: Sep 15, 2004 @ 2:24am
by kornalius

PostPosted: Sep 15, 2004 @ 3:17am
by sponge

PostPosted: Sep 15, 2004 @ 4:26am
by PointOfLight
Sponge, MSDN is your friend. Make MSDN your friend. I used it quite extensively when I was putting together the ListView_lib.ppl and TreeView_lib.ppl libraries (which I believe are both included in the distribution now). Even though the syntax on everything might not always be identical, it is usally pretty close.

Kornalius, I know the INI stuff isn't difficult, but if you don't have time to throw together a demo, I could do that for you. Let me know if you need a hand.

PostPosted: Sep 15, 2004 @ 2:53pm
by kornalius

PostPosted: Sep 15, 2004 @ 2:55pm
by PointOfLight

PostPosted: Sep 15, 2004 @ 3:01pm
by kornalius

PostPosted: Sep 15, 2004 @ 3:05pm
by PointOfLight

PostPosted: Sep 15, 2004 @ 6:39pm
by kornalius