Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: PowerBuilder
Expertise: Beginner
Feb 1, 1999

Power Script

Question:
I am reading in an external data file using i_file = fileopen ("c:\data\amt.dat", linemode!,read!)

	fileread (i_file, filelines)
		
fileclose (i_file)
How would you avoid hardcoding the data file so that at program start-up, it would pull the files from the default path installation?

Answer:
You can use the following API call to work out the current path:


Function ulong GetCurrentDirectoryA (ulong textlen, ref string dirtext) library "KERNEL32.DLL"
Then call the API call with PowerScript like:

String ls_Dir

IF ienv_ENV.win16 THEN RETURN ""

ls_dir = Space( 255 )

GetCurrentDirectoryA( 255, ls_dir )
IF Len( ls_dir ) > 1 AND Right( ls_Dir , 1 ) <> "\" THEN ls_Dir += "\"

RETURN ls_Dir
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date