Using C code

For general Flowcode discussion that does not belong in the other sections.
Post Reply
flowcode-developer
Posts: 37
http://meble-kuchenne.info.pl
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Flowcode v10 Using C code

Post by flowcode-developer »

I am using UART to get a string from a device. I then went to parse/trim that sting before I sent it to the PC. When I "compile to HEX" only the .h and .c files get generated. I think the problem is the C Code icon I am using. When I toggle it off the .hex gets generated. I have attached my code and the error message when the c code not toggled off.
Attachments
Inspectra_macro.fcfx
(16.6 KiB) Downloaded 42 times
Inspectra_macro.msg.txt
(4.32 KiB) Downloaded 42 times

User avatar
p.erasmus
Valued Contributor
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Flowcode v10 Re: Using C code

Post by p.erasmus »

Hi

What you see is normal FC/Compiler will not generate a hex file if there is an error in the code,
You have an error in the way you are parsing the strings (I would think you should use a loop do that)
anycase the problem is that your C code generates an error and therefore the hex file is not generated

P1.JPG
P1.JPG (78.53 KiB) Viewed 1085 times
Regards Peter - QME Electronics

Steve-Matrix
Matrix Staff
Posts: 1252
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: Using C code

Post by Steve-Matrix »

Your C code is illegal C. Specifically this line:

Code: Select all

// Remove the first 3 characters from the string
FCL_BUFFER = FCL_BUFFER + 3;
FCL_BUFFER is declared as an array in Flowcode (local string "buffer[20]").

You are probably best off avoiding C code and using a calculation similar to following:

Code: Select all

.buffer = Mid$(.buffer, 3, Length$(.buffer)-3)

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: Using C code

Post by medelec35 »

To learn more string functions, you can also use within a calculation box:

Code: Select all

.buffer = Right$ (.buffer, Length$ (.buffer) - 3)
As this is not a Flowcode bug, I have moved the topic from the Bugs section.
Martin

flowcode-developer
Posts: 37
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Re: Using C code

Post by flowcode-developer »

Thank you all! Where can I go to learn more about Length$, Mid$, Right$? They aren't C keywords and there isnt info in the Calculation Icon Properties wiki page.

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: Using C code

Post by medelec35 »

Hello.
You can find out about string functions on the Wiki here.
Martin

Post Reply