Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create folder

Posted on 2003-12-09
9
Medium Priority
?
4,306 Views
Last Modified: 2013-12-26
How can I create a folder in Windows
using Powerbuilder script?

For example, create  subfolder 'testing' in c:\temp.


0
Comment
Question by:xo123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 9903205
Description

Creates a directory.

Controls

File system

Syntax

CreateDirectory ( directoryname )

Argument      Description
directoryname      String for the name of the directory you want to create
Return value

Integer. Returns 1 if the function succeeds and -1 if an error occurs.
0
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 9903210
CreateDirectory( "c:\temp\testing" ) would be sufficient for u

Amit
0
 
LVL 33

Expert Comment

by:sajuks
ID: 9903229
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA) Library "KERNEL32" ALIAS FOR CreateDirectoryA

long ll_rc
string ls_path

ls_path = "C:\test\"
ll_rc = CreateDirectory(ls_path, 0)

if ll_rc = 1  then success
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Accepted Solution

by:
namasi_navaretnam earned 200 total points
ID: 9908655
It depedns on the PB version you are using. Use win API as sajuks suggests if you are PB 6.0 or earlier version. If not createdirectory function will do.

There is a file service object that come with PFC as well.

n_cst_filesrv inv_filesrv
f_SetFileSrv(inv_filesrv, TRUE)

inv_filesrv.of_CreateDirectory('c:\test')

HTH

Namasi



0
 

Author Comment

by:xo123
ID: 9909100
Yes, it's PB5 and doesn't support CreateDirectory.
How can I use win API in Powerbuilder?
How to declaure the function?
    FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL32" ALIAS FOR CreateDirectoryA

0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9909184
Open a window.
Then select "Declare/Global External Functions" or you want to delcare CreateDirectory as a global function or select "Declare/Local Exterbal Functions" menu if you want to use this function only in that window.
Then cut and paste,
FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL32" ALIAS FOR CreateDirectoryA

Now you can use CreateDirectory function anywhere in that window or anywhere in the code if declared as global external function.

Is yours 16 bit or 32 bit PB? This will not work with 16 bit PB as the declaration is little bit different for 16 bit PB.

HTH

Namasi Navaretnam





0
 

Author Comment

by:xo123
ID: 9909535
Great Thanks!
I'm using 32 bit PB.
But how to declare it if it's 16 bit?  Is it:
   FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL16" ALIAS FOR CreateDirectoryA
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9909545
Yes. For 32 bit,

FUNCTION long CreateDirectory (string lpPathName, ulong lpSA)Library "KERNEL16" ALIAS FOR CreateDirectoryA
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9909552
This is an example from Sybase,

CreateDirectoryA( )
This function create a new directory folder under the current directory, which under PowerBuilder would be 'c:\pwrs\pb5i32' if you installed shortnames. The second argument is exclusively used by NT and can be ignored under Win95. There is no PowerBuilder equivalent.

Global External Function:
FUNCTION boolean CreateDirectoryA(ref string pathname, int sa) LIBRARY "Kernel32.dll"

Script:
boolean rtn
string l_dir
l_dir = "API Demo"
rtn = CreateDirectoryA(l_dir, 0)
If rtn then
MessageBox("New Directory Created", "API Demo directory is located under pwrs.")
else
MessageBox("CreateDirectory", "Failed")
end if
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question