Gambas/Exist

From Wikibooks, the open-content textbooks collection

< Gambas
Jump to: navigation, search

back to Gambas

[edit] Does a File or Directory exist ?

Example:

PUBLIC SUB Button1_Click()
  IF Exist("/bin/bash") = TRUE THEN
  Label1.Text="OK i found Bash"
END IF
  IF Exist("/bin/bash") = FALSE THEN
  Label1.Text="Error Bash is missing"
END IF
 END


[edit] Get system's root / home folder ?

Example :

'Created : Cijo Jose 'E-mail  : info.cijo@gmail.com 'Job ID  : Junior Software Engineer

PUBLIC SUB Button1_Click()

dir_name as string

dir_name = system.root ' Will return root folder

print dir_name

dir_name = system.home ' Will return home folder

print dir_name

END


When you click on your button your gambas program checks for Bash if Bash is found then Label1 displays "OK i found Bash" if Bash is not found then Label1 displays "Error Bash is missing"

Gambas.SteveStarr - 02 Aug 2005