having a bit of trouble with documentation....

MichaelTJ

Member
Licensed User
Longtime User
i go to the forum for help but frequently end up spending all kinds of time looking at code that does not work for one reason or another.... being very new to B4A i am looking for simple strait forward examples.... the documentation for "copy" and "copy2" does not explain why both are needed and doing so might be useful along with concrete code examples.. ARE there actual working code examples anywhere to be seen?


SOMETHING LIKE.....
Dim SourceFile, DestinationFile As String
SourceFile = "SRCFILE" ' Define source file name.
DestinationFile = "DESTFILE" ' Define target file name.
Copy(SourceFile, DestinationFile) ' Copy source to target.

FOLLOWED BY....(important)
Dim SourceFile, DestinationFile As String
SourceFile = "/mnt/sdcard/testfile.csv"
DestinationFile = "/mnt/sdcard/external_sd/Books/testfile.csv"
Copy(SourceFile, DestinationFile)

i'm just guessing at the above and do not know if a file can be renamed during the operation

i'd think it very useful if something like the above were included as a part of the explanation for "copy" and "copy2"

can i find the sort of guidance given by the "FOLLOWED BY.." sample above?
 

yttrium

Active Member
Licensed User
Longtime User
Copy2 copies data between two data streams. You wish to copy files.

The documentation for Copy states:

B4X:
Copy (DirSource As String, FileSource As String, DirTarget As String, FileTarget As String)

Copies the specified source file to the target file name.
Note that it is not possible to copy files to the Assets folder.

Dir means directory, so for your example given, your code would be:

B4X:
Copy(File.DirRootExternal, "testfile.csv", File.Combine(File.DirRootExternal, "/external_sd/Books/"), "testfile.csv")
 
Upvote 0

MichaelTJ

Member
Licensed User
Longtime User
"Copy" is red....

i simply pasted what you provided intending to modify it for my needs but the "Copy" is in red text.... what have i missed?
 
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
i simply pasted what you provided intending to modify it for my needs but the "Copy" is in red text.... what have i missed?

Sorry, the correct method is File.Copy
 
Upvote 0

JesseW

Active Member
Licensed User
Longtime User
Although basic4android is very powerful indeed, it doesn't carry the level of documentation that microsoft, apple and google development solutions do, because it's developed and maintained by a single person, instead of teams of individuals, some of who are devoted entirely to documentation. The forum and trial-and-error are the best solutions to clear up any questions you may have. I absolutely love basic4android, but agree that documentation could have more how-to information included. Perhaps us users could help out in that area :)
 
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
Although basic4android is very powerful indeed, it doesn't carry the level of documentation that microsoft, apple and google development solutions do, because it's developed and maintained by a single person, instead of teams of individuals, some of who are devoted entirely to documentation. The forum and trial-and-error are the best solutions to clear up any questions you may have. I absolutely love basic4android, but agree that documentation could have more how-to information included. Perhaps us users could help out in that area :)

Being users who work with other users all day may allow us to make alternative documentation on the Wiki.
 
Upvote 0
Top