New topic: recursive copying
<http://forums.realsoftware.com/viewtopic.php?t=47244> Page 1 of 1 [ 8 posts ] Previous topic | Next topic Author Message JayBird Post subject: recursive copyingPosted: Sun Mar 10, 2013 9:50 am Joined: Thu Mar 17, 2011 6:12 pm Posts: 73 Hi all, i am very very new to Real Studio and am having issues with copying folders. I was pointed towards a copying psude-code but i cannot understand it. This is what i was given : CopyFolder(src as folderitem,dest as folderitem) dim m as integer for m = 1 to src.count if src.item(m) <> nil then if src.item(m).directory then dest.child(src.item(m).name).createAsFolder CopyFolder(src.item(m), dest.child(src.item(m).name)) else src.item(m).copyFileTo dest end if end if next When i look at it i see that src and dest need to be specified so i have done the following: dim src as FolderItem dim dest as FolderItem src=SpecialFolder.Desktop.Child("FolderA") dest=SpecialFolder.Desktop.Child("FolderB") and placed that at the top. The error code kicked out of this is that CopyFolder is not defined. I cannot see from the code given where or even how you define it? In my code Source and Destination are static.... Top DaveS Post subject: Re: recursive copyingPosted: Sun Mar 10, 2013 9:56 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4651 Location: San Diego, CA Quote: The error code kicked out of this is that CopyFolder is not defined. I cannot see from the code given where or even how you define it? The name of the procedure that you posted should be "COPYFOLDER" ... and yes it would be calling itself _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top JayBird Post subject: Re: recursive copyingPosted: Sun Mar 10, 2013 10:05 am Joined: Thu Mar 17, 2011 6:12 pm Posts: 73 dim src as FolderItem dim dest as FolderItem src=SpecialFolder.Desktop.Child("FolderA") dest=SpecialFolder.Desktop.Child("FolderB") COPYFOLDER(src as FolderItem,dest as FolderItem) dim m as integer for m = 1 to src.count if src.item(m) <> nil then if src.item(m).directory then dest.child(src.item(m).name).createAsFolder CopyFolder(src.item(m), dest.child(src.item(m).name)) else src.item(m).copyFileTo dest end if end if next States Syntax error..... ** note this has been placed on a submit button Top DaveS Post subject: Re: recursive copyingPosted: Sun Mar 10, 2013 10:14 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4651 Location: San Diego, CA SUBMIT BUTTON ACTION CODE dim src as FolderItem dim dest as FolderItem src=SpecialFolder.Desktop.Child("FolderA") dest=SpecialFolder.Desktop.Child("FolderB") COPYFOLDER(src as FolderItem,dest as FolderItem) GLOBAL PROCEDURE (in a MODULE) SUB COPYFOLDER(src as FolderItem,dest as FolderItem) dim m as integer for m = 1 to src.count if src.item(m) <> nil then if src.item(m).directory then dest.child(src.item(m).name).createAsFolder CopyFolder(src.item(m), dest.child(src.item(m).name)) else src.item(m).copyFileTo dest end if end if next END SUB _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top Sky Stream Post subject: Re: recursive copyingPosted: Sun Mar 10, 2013 10:16 am Joined: Sun Nov 23, 2008 12:27 am Posts: 398 Location: New Jersey Jay, Take a look at this post: http://forums.realsoftware.com/viewtopic.php?f=1&t=46709 Kem provided example code for what you are looking to do as well as checks source / destination file to ensure 1 to 1 match. _________________ - Rich Top JayBird Post subject: Re: recursive copyingPosted: Sun Mar 10, 2013 10:19 am Joined: Thu Mar 17, 2011 6:12 pm Posts: 73 Hey Dave, Thanks. Ive corrected the syntax: dim src as FolderItem dim dest as FolderItem src=SpecialFolder.Desktop.Child("FolderA") dest=SpecialFolder.Desktop.Child("FolderB") COPYFOLDER(src,dest) Last edited by JayBird on Sun Mar 10, 2013 10:26 am, edited 1 time in total. Top DaveS Post subject: Re: recursive copyingPosted: Sun Mar 10, 2013 10:24 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4651 Location: San Diego, CA Can't help if you don't provide WHERE you are getting an error _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top JayBird Post subject: Re: recursive copyingPosted: Sun Mar 10, 2013 10:34 am Joined: Thu Mar 17, 2011 6:12 pm Posts: 73 Thanks again for all the help, is there any beginners (idiots) guides you can direct me to at all? Also, is there anyway to stop the GUI from freezing up while copy is running while using the above? Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 8 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
