filebox1.path = dirbrowser1.path

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
theyikes
Posts: 17
Joined: Wednesday 18th September 2024 7:05pm

filebox1.path = dirbrowser1.path

Post by theyikes »

Hey! Ok I've been using Gambas for about 20 minutes, it's cool! So far I've managed to create folders and files but I'm kind of stuck on this one. I have a filebox and a dirbrowser. I'd like to be able to change the filebox directory to match the Dirbrowser one when i click on the browser. I know it's basic but i kind of need your help. I promise it's the first and last question of the night people!

Regard
The Yikes
theyikes
Posts: 17
Joined: Wednesday 18th September 2024 7:05pm

Re: filebox1.path = dirbrowser1.path

Post by theyikes »

it's okay, i figured it out, for those who may be following in my footsteps the answer is FileBox1.Path = DirChooser1.SelectedPath
theyikes
Posts: 17
Joined: Wednesday 18th September 2024 7:05pm

Re: filebox1.path = dirbrowser1.path

Post by theyikes »

on a seperete question I'm trying to create a folder. I can use
mkdir "/home/Auser/Desktop/gambas4"
but i cannot use
Mkdir FileChooser1.SelectedPath "Gambas4"
any tips?
User avatar
thatbruce
Posts: 225
Joined: Saturday 4th September 2021 11:29pm

Re: filebox1.path = dirbrowser1.path

Post by thatbruce »

theyikes wrote: Wednesday 18th September 2024 7:46pm Mkdir FileChooser1.SelectedPath "Gambas4"
Mkdir FileChooser1.SelectedPath &/ "Gambas4"
theyikes
Posts: 17
Joined: Wednesday 18th September 2024 7:05pm

Re: filebox1.path = dirbrowser1.path

Post by theyikes »

Thank you The Bruce! Love the name!!! I have one more quick question. It has to do with error handling. When i execute my script and i create a folder is there anyway of preventing from crashing if i try to recreate said folder? Please excuse the newbie questions but I'm only a little bit experienced in visual basic.

Regards:

TheYikes
User avatar
BruceSteers
Posts: 1831
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: filebox1.path = dirbrowser1.path

Post by BruceSteers »

Use Try to catch errors
Error management Gambas wiki

Try MkDir FileChooser1.SelectedPath &/ "Gambas4"
If Error Then
  Message.Error(Error.Text & "\n" FileChooser1.SelectedPath &/ "Gambas4")
Endif


This is a good read for new starters https://gambaswiki.org/wiki/cat
Welcome to the wonderful world of gambas :)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
gbWilly
Posts: 102
Joined: Friday 23rd September 2016 11:41am
Location: Netherlands
Contact:

Re: filebox1.path = dirbrowser1.path

Post by gbWilly »

theyikes wrote: Wednesday 18th September 2024 8:33pm When i execute my script and i create a folder is there anyway of preventing from crashing if i try to recreate said folder?
An other option:
If Not Exist(FileChooser1.SelectedPath &/ "Gambas4")
  Mkdir FileChooser1.SelectedPath &/ "Gambas4"
Endif
gbWilly
- Dutch translation for Gambas3
- Gambas wiki content contributer
- Gambas3 Debian repository


... there is always a Catch if things go wrong!
Post Reply