Example 1 - copy file in 4 lines

<< Click to Display Table of Contents >>

Navigation:  Introducing ThinBASIC >

Example 1 - copy file in 4 lines

 

This script will copy a file into a Windows temporary directory. This is a simple 4 line script.

All lines of code are outside any "user defined function" so this code will be executed immediately.

 

'----------------------------------------------------------------------

 

 

uses "file", "os"   ' Tell thinBasic you need "file" and "os" module

 

' Define a string variable containing the name of the file to copy FROM.

' Function app_sourcePath returns the path of the running script

dim fileSource as string = app_sourcePath & "Test.txt"

 

' Define a string variable containing the name of the file to copy TO.

' Note the alternative short form of variable declaration.

' Function os_getTempDir returns the path of the Temporary directory defined in your OS environment

string fileDest = os_getTempDir & "Test.txt"

 

'Copy the file into the new location with

file_copy (fileSource, fileDest)