knowledge-database (beta)

Current group: comp.soft-sys.powerbuilder

Re: I have problem with PB10. Scan directory files.

Re: I have problem with PB10. Scan directory files.  
Pawan Bagdiya
From:Pawan Bagdiya
Subject:Re: I have problem with PB10. Scan directory files.
Date:25 Nov 2004 02:55:35 -0800
Are you calling any external functions in this script, please check
the PB 10 help to declare the external function .. PB10 uses unicode
and external function declaration should use "Alias for "name>;ansi"

Please refer PB 10 help for this..

I not sure for this but still you can try this solution also.

Pawan





"Andrew Nagorny" wrote in message news:<2vj6voF2lhf8tU1@uni-berlin.de>...
> This script work in PB 8,10 very well. But, I have a crash in PB10.
> The crash PB10 can appear anytime.
> Help me please!
>
> PS. Directory "c:\Temp" must have files with mask *.sr?
>
> $PBExportHeader$w_tmp.srw
> forward
> global type w_tmp from window
> end type
> type mle_1 from multilineedit within w_tmp
> end type
> type sle_1 from singlelineedit within w_tmp
> end type
> type cb_1 from commandbutton within w_tmp
> end type
> type win32_find_dataa from structure within w_tmp
> end type
> type filetime from structure within w_tmp
> end type
> end forward
>
> type win32_find_dataa from structure
> unsignedlong dwfileattributes
> filetime ftcreationtime
> filetime ftlastaccesstime
> filetime ftlastwritetime
> unsignedlong nfilesizehigh
> unsignedlong nfilesizelow
> unsignedlong dwreserved0
> unsignedlong dwreserved1
> character cfilename[260]
> character calternatefilename[14]
> end type
>
> type filetime from structure
> unsignedlong dwlowdatetime
> unsignedlong dwhighdatetime
> end type
>
> global type w_tmp from window
> integer width = 1010
> integer height = 1396
> boolean titlebar = true
> string title = "Untitled"
> boolean controlmenu = true
> boolean minbox = true
> boolean maxbox = true
> boolean resizable = true
> long backcolor = 67108864
> string icon = "AppIcon!"
> boolean center = true
> mle_1 mle_1
> sle_1 sle_1
> cb_1 cb_1
> end type
> global w_tmp w_tmp
>
> type prototypes
> Function ulong FindFirstFileA (string lpFileName, ref WIN32_FIND_DATAA
> lpFindFileData) Library "KERNEL32.DLL" Alias for "FindFirstFileA;Ansi"
> Function boolean FindNextFileA (ulong hFindFile, ref WIN32_FIND_DATAA
> lpFindFileData) Library "KERNEL32.DLL" Alias for "FindNextFileA;Ansi"
> end prototypes
>
> forward prototypes
> public function boolean of_getbit (long al_decimal, unsignedinteger ai_bit)
> public function integer of_getfilelist (string as_rootdirectory, string
> as_filemask, boolean ab_subdirectory, ref string as_filename[])
> public function integer of_getsubdirectories (string as_rootdirectory, ref
> string as_filename[])
> end prototypes
>
> public function boolean of_getbit (long al_decimal, unsignedinteger
> ai_bit);Boolean lb_null
>
> //Check parameters
> If IsNull(al_decimal) or IsNull(ai_bit) then
> SetNull(lb_null)
> Return lb_null
> End If
>
> //Assumption ai_bit is the nth bit counting right to left with
> //the leftmost bit being bit one.
> //al_decimal is a binary number as a base 10 long.
> If Int(Mod(al_decimal / (2 ^(ai_bit - 1)), 2)) > 0 Then
> Return True
> End If
>
> Return False
>
> end function
>
> public function integer of_getfilelist (string as_rootdirectory, string
> as_filemask, boolean ab_subdirectory, ref string
> as_filename[]);WIN32_FIND_DATAA lpFindFileData
> ULong lul_handle
> Long ll_count
> String ls_dirmask = '*'
> String ls_filename
> String ls_subdirectory[]
> Integer li_i,li_up
> String ls_tmp
>
> ll_count = UpperBound(as_filename)
> //File
> ls_tmp = as_rootdirectory+'\'+as_filemask
> lul_handle = FindFirstFileA(ls_tmp,lpFindFileData)
> do while lul_handle >0
> if Not of_GetBit(Long(lpFindFileData.dwFileAttributes),5) then
> ls_filename = Trim(lpFindFileData.cFileName)
> lpFindFileData.cFileName = ''
> if Len(ls_filename) > 0 then
> ll_count ++
> if ab_subdirectory then ls_filename = as_rootdirectory+'\'+ls_filename
> as_filename[ll_count] = ls_filename
> end if
> end if
> if Not FindNextFileA(lul_handle,lpFindFileData) then EXIT
> loop
>
> //SubDirectory
> if ab_subdirectory then
> li_up = of_GetSubDirectories(as_rootdirectory,ls_subdirectory)
> For li_i = 1 to li_up
> of_GetFileList(as_rootdirectory +
> '\'+ls_subdirectory[li_i],as_filemask,ab_subdirectory,as_filename)
> Next
> end if
>
> Return UpperBound(as_filename)
> end function
>
> public function integer of_getsubdirectories (string as_rootdirectory, ref
> string as_filename[]);WIN32_FIND_DATAA lpFindFileData
> ULong lul_handle
> Long ll_count
> String ls_dirmask = '*'
> String ls_filename
> String ls_tmp
>
> ls_tmp = as_rootdirectory+'\'+ls_dirmask
>
> lul_handle = FindFirstFileA(ls_tmp,lpFindFileData)
> do while lul_handle >0
> ls_filename = Trim(lpFindFileData.cFileName)
> lpFindFileData.cFileName = ''
> if Len(ls_filename) > 0 then
> if Not(ls_filename ='.' Or ls_filename = '..') then
> if of_GetBit(lpFindFileData.dwFileAttributes,5) then
> ll_count ++
> as_filename[ll_count] = ls_filename
> end if
> end if
> end if
> if Not FindNextFileA(lul_handle,lpFindFileData) then EXIT
> loop
>
> Return UpperBound(as_filename)
>
> end function
>
> on w_tmp.create
> this.mle_1=create mle_1
> this.sle_1=create sle_1
> this.cb_1=create cb_1
> this.Control[]={this.mle_1,&
> this.sle_1,&
> this.cb_1}
> end on
>
> on w_tmp.destroy
> destroy(this.mle_1)
> destroy(this.sle_1)
> destroy(this.cb_1)
> end on
>
> type mle_1 from multilineedit within w_tmp
> integer y = 308
> integer width = 928
> integer height = 880
> integer taborder = 20
> integer textsize = -10
> integer weight = 400
> fontcharset fontcharset = russiancharset!
> fontpitch fontpitch = variable!
> fontfamily fontfamily = swiss!
> string facename = "Arial"
> long textcolor = 33554432
> boolean hscrollbar = true
> boolean vscrollbar = true
> borderstyle borderstyle = stylelowered!
> end type
>
> type sle_1 from singlelineedit within w_tmp
> integer y = 4
> integer width = 891
> integer height = 112
> integer taborder = 10
> integer textsize = -10
> integer weight = 400
> fontcharset fontcharset = russiancharset!
> fontpitch fontpitch = variable!
> fontfamily fontfamily = swiss!
> string facename = "Arial"
> long textcolor = 33554432
> string text = "c:\temp"
> borderstyle borderstyle = stylelowered!
> end type
>
> type cb_1 from commandbutton within w_tmp
> integer x = 201
> integer y = 172
> integer width = 402
> integer height = 112
> integer taborder = 10
> integer textsize = -10
> integer weight = 400
> fontcharset fontcharset = russiancharset!
> fontpitch fontpitch = variable!
> fontfamily fontfamily = swiss!
> string facename = "Arial"
> string text = "Test"
> end type
>
> event clicked;int li_i,li_up
> String FileList[]
>
> li_up = of_GetFileList(sle_1.Text,'*.sr?',False,FileList)
>
> mle_1.Text=''
> For li_i=1 to li_up
> mle_1.Text=mle_1.Text+'~r~n'+FileList[li_i]
> Next
> end event
   

Copyright © 2006 knowledge-database   -   All rights reserved