Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reading multiple lines using ProfileString

346 views
Skip to first unread message

Amal Sharma

unread,
Nov 5, 2007, 7:39:36 AM11/5/07
to
Hello,

I am using PB 9.0.3. I would like to read multiple lines (a bunch of SQL
statements) from a INI file using one key value and ProfileString function.
I do not wish to combine all the lines into a single line as that will be
unreadable & unmangeable. Is there some way to read multiple lines
corresponding to a key value from a configuration file. Probably by giving
some line continuation character etc or any other alternative.

The only other alternative is for me to write code to read lines till I
reach another section.

TIA
Amal


Chris Pollach

unread,
Nov 5, 2007, 8:05:54 AM11/5/07
to
Amal;

Why don't you make an entry in the INI that points to a text file. Then
use the FileReadEX ( ) method to grab the whole chuck of text in one easy
go.

Food for thought.

Regards .. .Chris


"Amal Sharma" <amsharma AT abhikalak DOT com> wrote in message
news:472f0f08$1@forums-1-dub...

Terry Voth [TeamSybase]

unread,
Nov 5, 2007, 9:51:48 AM11/5/07
to
What you are asking for really defies the Microsoft definition of an INI
file, so you won't likely find a pre-built solution. While you could
write a routine that reads your INI-in-name-only file, I'd suggest
Chris' solution of an INI entry pointing to a file is far cleaner,
maintaining the configuration file as a true INI file, and avoiding the
ugliness of continuation characters.

Good luck,

Terry [TeamSybase] and Sequel the techno-kitten

Amal Sharma wrote:

--
*********************************
Need to get up to speed on PB11? In North America?
http://www.isug.com/pb11tour
*********************************
Click once a day to help the hungry
http://www.thehungersite.com
*********************************
Newsgroup User Manual
=====================
TeamSybase <> Sybase employee
Forums = Peer-to-peer
Forums <> Communication with Sybase
IsNull (AnswerTo (Posting)) can return TRUE
Forums.Moderated = TRUE, so behave or be deleted
*********************************

Sequel's Sandbox: http://www.techno-kitten.com
Home of PBL Peeper, a free PowerBuilder Developer's Toolkit.
Version 3.0.02 now available at the Sandbox
PB Futures updated Apr 24/2006
See the PB Troubleshooting & Migration Guides at the Sandbox
^ ^
o o
=*=

Amal Sharma

unread,
Nov 7, 2007, 7:14:50 AM11/7/07
to
Thanks for your reply.

I couldn't find the function FileReadEX() in the help. Probably I am missing
something.

I can also understand what Terry wrote. Just one clarification I will have
have multiple of these Keys in one file (and they will keep growing) so
having that many text files would not be an elegant solution.

Amal

"Chris Pollach" <cpol...@travel-net.com> wrote in message
news:472f1532$1@forums-1-dub...

Chris Pollach

unread,
Nov 7, 2007, 7:37:38 AM11/7/07
to

You must be on a very old release of PB!

From PB 10.5.2 ...
--------------------------------------------------------------
FileReadEx ( file#, blob {, length } )
FileReadEx ( file#, string )

Argument Description
file# The integer assigned to the file when it was opened.
blob or string The name of the string or blob variable into which you want
to read the data.
length In text or stream mode, the number of bytes a retrieve requires. The
default value is the length of the file.
---------------------------------------------------------------

HTH

"Amal Sharma" <amsharma AT abhikalak DOT com> wrote in message

news:4731ac3a$1@forums-1-dub...

Terry Voth [TeamSybase]

unread,
Nov 7, 2007, 11:27:41 PM11/7/07
to
FileReadEx was introduced in PB10 (http://tinyurl.com/243aw6). FileRead
will do just fine.

Good luck,

Terry [TeamSybase] and Sequel the techno-kitten

--

Clive Collie

unread,
Nov 8, 2007, 5:04:36 AM11/8/07
to
Thhe PB Profilestring functions doesn't let you do this.

An ini file does not allow multi line values. It is always in the format
[section]
key=value~r~n

It will read a key up to the ~r~n (there is a limit on the number characters
but I don't know how many offhand)

You could use the the win32 API to read ini files: GetPrivateProfileString
(look it up on MSDN.microsoft.com) which is capable of reading a whole
section in one go
[section]
key1=begin line
key2=continue
key3=end line

Unfortunatly it returns the lines in an difficult to use format for PB with
each line ending in \x0 character and the last line with \x0\x0.
Microsoft would rather you used the registry. I suspect the roll your own
solution is the best as suggested by the others (fileread in linemode).

"Amal Sharma" <amsharma AT abhikalak DOT com> wrote in message
news:472f0f08$1@forums-1-dub...

0 new messages