Why does it want a boxed string?
Posted
#1
(In Topic #1565)
Regular

Not sure what has happened, part of my code which was working is now failing with error
Type mismatch: wanted _BoxedString, got String instead
this is the offending line
the error implies workingImLoc is a boxed String but I've only just declared it (as a string) in the above line and it's not declared as a boxed string
the contents of FMain.imageLocation is a normal String with the following content "/home/simon/Documents/Gambas/Sol_Observer1.7/2025-07-16-0701_6-Capture_Focus_lapl2_ap514_REFPS.jpg"
it is declared in FMain as follows
As I said this changed when I was working on a different class (for a save form) which doesn't even get initiated at this point in the program, so not sure what I've done wrong, any ideas or suggestions?
Posted
Guru

FMain would not be created until it is accessed somehow.
By accessing the FMain variable you then create the form.
The error is probably in FMain somewhere.
I assume a lot as you have not provided an example just some little bits of code.
Posted
Regular

FMain is the start-up class, it is the first form that appears, the project is quite large I can share the whole thing but didn't think it wise give it is reasonably large
FMain starts like this
imageLocation is populated by FOpen (FOpen is a file open dialogue called from a menu event in FMain) as follows…
Code (gambas)
- FMain.UpdateStatus("gb.CLS")
- FMain.UpdateStatus("IMAGE PATH:" & "<b>" & FMain.imageLocation & "</b>")
- FMain.imageLocation = ""
- saveSettings() 'save the selected directory
- closeDown()
I select as file using FOpen and FMain.imageLocation is populated with "/home/simon/Documents/Gambas/Sol_Observer1.7/2025-07-16-0701_6-Capture_Focus_lapl2_ap514_REFPS.jpg" (or whatever file I selected) which is what I expected.
after the file is selected FOpen closes and the next relevant step in the process, calls getDatefromFileName() a function to extract some information from the file name, which crashes with the type mismatch error
Code (gambas)
- 'see if we can get date and time data from filename i.e. a WinJupos compliant filename
- 'requires filename starts with the format YYYY-MM-DD-HHmm to retreive date and time from filename
- ' Dim
- _Year = -9999
- _Year = -9999
- _Year = -9999
- _Year = -9999
- _Year = -9999
- _Year = -9999
Here is the project.
Posted
Guru

So i got the same error and upon investigating i found File.Name was expecting a string as a property, not the method with arguments.
The reason was thus..
In fOrig.form you have a Menu named File
this overrides/breaks the use of File.class causing your use of File.Name to be the same as Menu.Name
You should not use any words as Name for Menus/Controls that are gambas classes or function names
So change the File Menu name to mnuFile or something like that and all will be fixed
Posted
Guru

You could have spent days posting snippets of code and we would still never have found the problem.
With an example that produces the problem or the project itself it all becomes clear so much easier
Posted
Regular

1. Bruce, you are awesome
2. Share the code
3. Did I mention you are awesome
Posted
Guru

DIYTinkerer said
OK I've learnt three lessons today.
1. Bruce, you are awesome
2. Share the code
3. Did I mention you are awesome
Haha, to be fair I got that from Benoit.
One of the first things he asks when you report an issue is "please provide a project that reproduces the problem"
It makes sense and has many benefits.
Many times I have found the problem in my own code while making a sample project that for some reason will not reproduce the problem and helps me find where i went wrong.
1 guest and 0 members have just viewed this.


