devxlogo

Power Script

Power Script

Question:
I am reading in an external data file using i_file = fileopen (“c:dataamt.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_DirIF 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
See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist