2013-10-14 4 views
2

그래서 메인 디렉토리 내에 디렉토리를 만들고 그 새로운 디렉토리 안에 여러 개의 폴더를 만드는 파스칼 스크립트를 만들고 있습니다.파스칼 : 배열을 통해 루프를 반복하여 폴더를 만드시겠습니까?

우리가 일하는 곳에서 우리가하는 일은 우리가이 변수들을 exe로 보낸 다음 전달되는 것을 기반으로 디렉토리를 생성합니다 (이 경우 path 'fullpath').

내가 올바르게 접근하고 있고 훨씬 더 눈에 띄는 파스칼 전문가의 입력 : 당신이 당신의 배열의 각 항목에 대한 절대 경로를 식별하면

const 
ARRAY1: Array[1..9] of String = (
    'NQN', 'Documents', 'Correspondences', 
    'Worksheets', 'Reports', 'Claims', 
    'Certificate of Insurance', 'Invoice', 'Monthly Reports' 
); 
var 
i: Integer; 
fullpath, path, name, os, es, cmd: String; 
Code : LongWord; 
res: Integer; 

Begin 
path := 'Policies' 
fullpath := path+'\'+[i] 
    for i := 1 to 9 do 
    IF(ReqList.Values['sRM_ID'] = '') then 
     Begin 
      cmd := 'C:\XXX\bin\mkdir.exe "'+fullpath+'"'; 
      res :=ExecuteProc(cmd, 'C:\XXX\bin', true, -1, true, nil, os, es, code); 
      if(res = 0) then 
       Begin 
        ReqList.values['NoErrors'] := '1'; 
        ReqList.Values['Response_content']:= '{"valid":"1","message":"'+ReplaceString(ReplaceString(os,#13,'',false),#10,'',false)+'"}'; 
       end 
      else 
       begin 
        ReqList.Values['NoErrors'] := '0'; 
        Reqlist.Values['Response_Content'] := '{"valid":"0","message":"'+ReplaceString(ReplaceString(os,#13,'',false),#10,'',false)+'"}'; 
       end; 
     END 
     ELSE 
       Begin 
        ReqList.Values['Response_Content'] := '{"valid":"0","message":"A folder or file with the same name already exists."}'; 
       End; 
        ReqList.Values['Response_ContentType'] := 'HTML'; 
+3

가 [ForceDirectories]에보고 (http://docs.embarcadero.com/products/을 가지고 :

, 그것은이처럼 간단 할 수있는 루트 경로를 현재의 실행 파일 경로를 기준으로 가정 rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/SysUtils_ForceDirectories.html) * 실제 * (완전한) 전체 표기법을 사용하십시오. – bummi

+1

스크립팅 작업에 스크립팅 언어를 사용하는 것이 더 적합 할 것입니다 –

+0

exe는 사전 결정된 디렉토리를 사용하고 제공된 경로를 기반으로 이러한 폴더의 대상을 갖습니다. ForceDirectories에 대해이 탭을 유지하려고합니다. 매우 유용 할 것 같기 때문입니다. – Doodely

답변

4

, ForceDirectories 그들을 만들 것이다 사랑한다면 확실하지 않다 bummi가 위에 제시했던 것처럼 그들이 존재하지 않는다면.

관련 문제