Try missing End Try, but its right there -->
Posted
#1
(In Topic #1550)
Trainee

I do not know if I am running into a ChatGPT issue as it keeps sending me in a circle back to the same error or if this might be a bug inside Gambas.
What the program is suppose to do:
This program is intended to be a GUI program with one drop down box populated with names associated to IP addresses and a button. When the button is pressed it run a shell command of
<COLOR color="#FF0040">usbip list –remote=<IP></COLOR> with the IP address collected from the dropdown box.
Running this manually outputs a response that looks like:
Code
┌──(kali㉿kali)-[~]
└─$ usbip list -r 192.168.1.30
Exportable USB devices
======================
- 192.168.1.30
1-7: Realtek Semiconductor Corp. : Realtek 8812AU/8821AU 802.11ac WLAN Adapter [USB Wireless Dual-Band A
: USB\VID_0BDA&PID_0811\00E04C000001
: (Defined at Interface level) (00/00/00)
: 0 - Vendor Specific Class / Vendor Specific Subclass / Vendor Specific Protocol (ff/ff/ff)It then collects the busid # (1-7 in the example above) and run a shell command of "<COLOR color="#FF0040">usbip attach –remote=<IP> –busid=<ID#></COLOR>"
The issue:
When I hit the play button it stops and I get an error claiming "Unexpected end of line (FMain.class:39)"
Code (gambas)
From my research all I keep getting is that my code is missing an "END TRY" or "FINALIZE" to close the section out, but as you can see…its there. ?!?
Thanks for any help or guidance.
P.S. The "output123" and "line123" are named this way because when I tried to just use "output" or "line" as the name it would capitalize the O and the L and ChatGPT said the capitalization could be an issue. I could not get Gambas to type keep these lowercase so I just added 123 to the end to get past this being a possible issue.
FULL PROGRAM:
Code (gambas)
- ' Gambas class file
- ' Create a name-IP map
- cbb_NUCs.Clear
- ' Populate the ComboBox and IP Addresses
- ipMap["NUC 03"] = "192.168.1.3"
- ipMap["NUC 08"] = "192.168.1.8"
- ipMap["NUC 30"] = "192.168.1.30"
- cbb_NUCs.Add(name)
- ' Get IP from selected name
- ip = ipMap[SelectedName]
- ' Build and run command
- cmd = "usbip list --remote=" & ip
- ' Capture the output from the usbip list command
- ' Iterate through the output and look for the Realtek 8812AU adapter
- Exit ' Exit the loop when the adapter is found
- ' Run the attach command
- cmd = "usbip attach --remote=" & ip & " --busid=" & busid
Posted
Administrator



ChatGTP produces non sense code and non sense answers, stay away from it. I didn't even bother looking at further code after seeing the fist part :shock: .mouse51180 said
I do not know if I am running into a ChatGPT issue as it keeps sending me in a circle back to the same error or if this might be a bug inside Gambas.
Have you ever tried asking the Gambas wiki. Adding these 3 words (gambas wiki try) in a search engine gave me: https://gambaswiki.org/wiki/lang/try.
Start there and TRY
gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories
… there is always a Catch if things go wrong!
Posted
Banned
Read the wiki, AI is rubbish and gives you wrong answers, AI will not really help you, only confuse you.
For example…
"Try" is for a single line statement only.
There is no such syntax as "End Try" in gambas.
/lang/try - Gambas Documentation
And "Catch" can only be used as the final lines of code. If there is any error raised all code after "Catch" will be run.
/lang/catch - Gambas Documentation
If you had read the gambas wiki for "Try" and "Catch" you would have seen how your code does not make sense.
To stop a command raising an error and check the error state yourself you use "Try" , like this…
Code (gambas)
- ' Capture the output from the usbip list command
- ' "Try" to run a statement and then check for any error...
Posted
Banned
/lang - Gambas Documentation
/lang/output - Gambas Documentation
/lang/lineinput - Gambas Documentation
Posted
Trainee

1 guest and 0 members have just viewed this.


