This site is no longer active and is available for archival purposes only. Registration and login is disabled.

FOPEN/READSTRING Oddities


FOPEN/READSTRING Oddities

Postby sponge » Sep 14, 2004 @ 11:51pm

holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby kornalius » Sep 15, 2004 @ 12:03am

Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby sponge » Sep 15, 2004 @ 12:28am

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 ;)
holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby kornalius » Sep 15, 2004 @ 12:45am

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.
Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby sponge » Sep 15, 2004 @ 1:23am

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?
holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby kornalius » Sep 15, 2004 @ 1:37am

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.
Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby sponge » Sep 15, 2004 @ 1:40am

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!
holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby kornalius » Sep 15, 2004 @ 2:24am

Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby sponge » Sep 15, 2004 @ 3:17am

holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby PointOfLight » Sep 15, 2004 @ 4:26am

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.
Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Sep 15, 2004 @ 2:53pm

Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Sep 15, 2004 @ 2:55pm

Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Sep 15, 2004 @ 3:01pm

Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby PointOfLight » Sep 15, 2004 @ 3:05pm

Eric Pankoke
Programmer
Point Of Light Software
http://www.polsoftware.com/
PointOfLight
pm Member
 
Posts: 525
Joined: Nov 2, 2003 @ 8:39pm


Postby kornalius » Sep 15, 2004 @ 6:39pm

Regards,
Kornalius
President
ArianeSoft Inc.
http://www.arianesoft.ca
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Next

Return to Pocket Programming Language (PPL)


Sort


Forum Description

Discuss this new development tool.

Moderator:

kornalius

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron