Flowcode document name

Post and discuss new components that you have created.
Post Reply
Xbiotec
Posts: 222
http://meble-kuchenne.info.pl
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 36 times
Been thanked: 26 times

Flowcode v10 Flowcode document name

Post by Xbiotec »

Hello,
is it possible to get the name of the .fcfx and store it in a variable to be able to use it in the firmware ?
if the file name is for example: R IDF 5.3 Test12.fcfx
the name will be "R IDF 5.3 Test12"

Thx
Seb

Steve-Matrix
Matrix Staff
Posts: 1662
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 233 times
Been thanked: 393 times

Re: Flowcode document name

Post by Steve-Matrix »

Hopefully the attached project shows you how to do it. I used a combination of the "AddConst" event to manipulate the value (and size) of a constant and the "Expand.PathName" to retrieve the name of the file.

If you compile the project, the "MYFILENAME" Flowcode constant should be set to the name of the actual Flowcode project file.
Attachments
put filename into firmware.fcfx
(9.83 KiB) Downloaded 10 times

Xbiotec
Posts: 222
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 36 times
Been thanked: 26 times

Flowcode v10 Re: Flowcode document name

Post by Xbiotec »

thank you but , in fact, I don't know how to use it in my program
Seb

Steve-Matrix
Matrix Staff
Posts: 1662
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 233 times
Been thanked: 393 times

Re: Flowcode document name

Post by Steve-Matrix »

Here are the steps that I did to create it in that attached project:
  1. Create a global constant
  2. Double-click the Compile::Ev_AddConst event in Project Explorer
  3. Double-click <Add new>
  4. Click "OK"
  5. Click "OK and Edit Macro"
  6. Add code as per my example to the Ev_AddConst macro
If the "Events" tab is not showing in your Project Explorer, you can add it via the "UI Trees" tab in Global Options.

Xbiotec
Posts: 222
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 36 times
Been thanked: 26 times

Re: Flowcode document name

Post by Xbiotec »

1- Create a global constant
what should be the name of the constant ?
Which kind of constant, String or other ?

6- Add code as per my example to the Ev_AddConst macro
If add by copy past the code, the local variables do not exist, so need to create one by one isn't ?
Seb

Steve-Matrix
Matrix Staff
Posts: 1662
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 233 times
Been thanked: 393 times

Re: Flowcode document name

Post by Steve-Matrix »

The constant is a string and should be called "MYFILENAME".

Yes, you will need to create the variables. The alternative is to export the macro from my project and import it into your project. This will retain the local variables, but you will need to manually link this to the AddConst event (double click the event and select the imported macro).

This all involves advanced use of Flowcode and many of these features (events and inbuilt functions) are typically only used when creating components.

We might add this feature to an existing Flowcode component (e.g. the "Auto Version Identifier" component), which will make it a lot easier to add to existing projects.

Attached is a very basic component that I've just created to allow this. The fcfx file is the source code and the fcpx file is the exported component. You should make this exported component available using the "Look for components in..." entry of Global Options. See here:
https://www.flowcode.co.uk/wiki/index.p ... #Locations
Attachments
AddFilenameToCode.fcpx
(2.36 KiB) Downloaded 6 times
FileInfo.fcfx
(13.56 KiB) Downloaded 7 times

stefan.erni
Valued Contributor
Posts: 1133
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 215 times
Been thanked: 237 times

Re: Flowcode document name

Post by stefan.erni »

Hi Seb, Hi Steve

Good idea and useful.
I have added the components to my program and am sending the filename to the iPhone via BLE.
It works very well.
Seed_S3_filename.fcfx
(14.47 KiB) Downloaded 6 times
printscreen Iphone:
IMG_5372.PNG
IMG_5372.PNG (59.47 KiB) Viewed 53 times

Xbiotec
Posts: 222
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 36 times
Been thanked: 26 times

Re: Flowcode document name

Post by Xbiotec »

Thx a lot Steve, it work's well
Seb

Post Reply