Nathan, 
here is a Code Snippet for copying files from an SD card on the CuWin3500 
device to a USB stick plugged into the CuWin3500. 

This code was written using NSBasic 7.0.5 and Uses the old Windows File and 
filesystem Dll's

I left out some Dim statements for the variables
and Addobject picture elements.

This is just to show you the flow. This will not run as is

Code Start
 
Option Explicit
ShowOKButton True 'Set minimize button URHC to close app

' make full screen hide taskbar and top menu
' Screen is 800 x 480
Dim hWnd
Dim nWidth
Dim nHeight
Dim bRepaint
Declare "Function GetForegroundWindow Lib ""Coredll"" () As Long"
Declare "Function MoveWindow Lib ""Coredll"" (ByVal hWnd As Long, ByVal x As 
Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal 
bRepaint As Long) As Long"
 hWnd = GetForegroundWindow
MoveWindow hWnd, 0, -26, Output.Width, 506, True ' 26 and 506
' need To hide the taskbar On Cuwin using a mouse in the USB port
Output.BackColor = &H00000000& ' Black background


Dim SrcePath ' "\Storage Card\SIDData\"
Dim SrceFName' "STID*.Txt"

Dim DestPath ' "\Hard Disk\SIDData\"' Subdirectory on the USB Drive, must be 
there to prevent an error
Dim DestFName '= DestPath & FLName
Dim FileCount ' Count number of Station ID Data Files
Dim Source '  "\Storage Card\SIDData\STID*.Txt"
Dim DataDir ' filesystem.dir(Source)
Dim FLLen ' Len(DataDir) ' is this the length of the file only?
Dim FLName ' Mid(DataDir,28,FLLen - 28))
Dim DestFileTest



' File System object to Copy Data Files to USB Hard Drive
AddObject "FileSystem", "FileSystem", 0, 0, 0, 0
AddObject "FileSystem", "FileSystem1", 0, 0, 0, 0

' File object to open/read/write Default and Station ID Data Files
AddObject "file"

' ------------------------------------------------------
Sub USBTransferScreen 

' Called in Dpic1_Click to transfer data to USB Stick
ScreenHeader.Picture = PathDeflt & DfVHdr  ' Gaea ... Powder Counter Default 
Values  

' Subdirectory on the SD Card
SrcePath = "\Storage Card\SIDData\"
SrceFName = "STID*.Txt"
' Subdirectory on the USB Drive, must be there to prevent an error
DestPath = "\Hard Disk\SIDData\"

'filesystem.FileCopy PathName, NewPathName

FileCount = 1
Source = "\Storage Card\SIDData\STID*.Txt"
  
DataDir = filesystem.dir(Source)
    SrceFName = SrcePath & DataDir
    DestFName = DestPath & DataDir
    Call USBFileCopy
 
   If DestFileTest = "" Then ' check to see if USB Drive is plugged in
    Exit Sub
   End If
              
   While (DataDir <> "")
     DataDir = fileSystem.Dir() ' each time envoked brings up a new file
      If DataDir <> "" Then 
       SrceFName = SrcePath & DataDir
       DestFName = DestPath & DataDir
       FileCount = FileCount +1
       Call USBFileCopy
      End If
   WEnd

Dpic1.picture = PathDeflt & DefPicR(1) ' TURN "Upload to USB Drive" Button 
background red
USBOperatorDone.show ' show the Done Button "Sub USBOperatorDone_click"

End Sub

' --------- Copy files from the SD Card to the USB Stick --------------------
Sub USBFileCopy
' Test if the USB Hard Disk is plugged in

DestFileTest = FileSystem1.Dir("\Hard Disk\USBCheck.dat")
If DestFileTest = "" Then
   Mpic6.DrawText " "
   Mpic6.DrawText "USB Drive Error"
   Mpic6.DrawText "No USB Device"
   Mpic6.DrawText "Insert USB Drive "
   Mpic6.DrawText "and Try Again... " 
   USBOperatorDone.show         
   UpdateScreen   
   Exit Sub
End If   
   
Mpic6.move 360,75,420,275 ' no next of back buttons   
Mpic6.TransparentColor = -1
Mpic6.BackColor = BlueBackColor
Mpic6.Cls
Mpic6.FontBold = True
Mpic6.FontSize = 30
Mpic6.ForeColor = &H0000FFFF&
Mpic6.show
Mpic6.DrawText FileCount & " Data Files"
Mpic6.DrawText "Copying ..."
Mpic6.DrawText SrcePath      
Mpic6.DrawText DataDir   
Mpic6.DrawText "to USB Drive"
Mpic6.DrawText DestPath

UpdateScreen

'Test If the file does Not exist yet
If (FileSystem1.Dir(DestFName) = "") Then
'  Then we can copy the file
   FileSystem.FileCopy (SrceFName), (DestFName)
ElseIf  (FileSystem1.Dir(DestFName) <> "") Then
   Mpic6.DrawText " "   
   Mpic6.DrawText "File Exists on Destination"
   UpdateScreen
End If

End Sub
Code Stop

This project was Formless, and 95 elemets were picture elements
i.e.
AddObject "NSCEPictureBox.NSCEPictureBoxCtrl.1","GeoL",60,40,400,150

Then use GeoL.hide and GeoL.show to hide and show specific elements at specific 
times and events. Use _Click events to move through the program

All objects were created using AddObject, no toolbox objects were used, because 
this was Formless.
All variables Dim'ed first, then all objects created and hidden, then specific 
objects shown, then using Click events, to run the program. 

Program contained 4550 lines, 

NSBasic ultimately worked well, but not without it's frustrations.

There is a learning curve, as with any programming language.

Hope this helps.

Ben


--- In nsbasic-ce@yahoogroups.com, "rmrsoft" <a...@...> wrote:
>
> Yes, that is what I meant.  I am not aware of the boolean operator but you 
> could be right.
> 
> --- In nsbasic-ce@yahoogroups.com, epankoke@ wrote:
> >
> > The tech note may not specifically show code for copy, but if you look at 
> > the Methods list for the file object, there is a method called FileCopy. If 
> > I had to guess, the parameters would be FileToCopyFrom, FileToCopyTo, and 
> > possibly an optional boolean to specify whether to fail or overwrite if the 
> > destination already exists. 
> > 
> > 
> > ----- Original Message ----- 
> > From: "Nathan" <eeepc904@> 
> > To: nsbasic-ce@yahoogroups.com 
> > Sent: Friday, March 5, 2010 4:42:17 AM GMT -05:00 US/Canada Eastern 
> > Subject: [nsbasic-ce] Re: Copy Files 
> > 
> > 
> > 
> > 
> > 
> > 
> > The third Tech Note doesn't cover Copy, only append, ... :( 
> > 
> > --- In nsbasic-ce@yahoogroups.com , "rmrsoft" <alan@> wrote: 
> > > 
> > > It's all covered in Tech Note 3e 
> > > 
> > > 
> > > --- In nsbasic-ce@yahoogroups.com , "Nathan" <eeepc904@> wrote: 
> > > > 
> > > > I don't like to be..., but someone can help me? 
> > > > 
> > > > --- In nsbasic-ce@yahoogroups.com , "Nathan" <eeepc904@> wrote: 
> > > > > 
> > > > > Hello, 
> > > > > I want to know how to copy files with NSBasic/CE 7.0 
> > > > > 
> > > > > Best Regards, 
> > > > > Nathan Paulino Campos 
> > > > > 
> > > > 
> > >
> >
>


-- 
You received this message because you are subscribed to the Google Groups 
"nsb-ce" group.
To post to this group, send email to nsb...@googlegroups.com.
To unsubscribe from this group, send email to 
nsb-ce+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/nsb-ce?hl=en.

Reply via email to