Page 1 of 1

Using C code

Posted: Wed Mar 01, 2023 12:35 am
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.

Re: Using C code

Posted: Wed Mar 01, 2023 6:24 am
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 1139 times

Re: Using C code

Posted: Wed Mar 01, 2023 9:26 am
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)

Re: Using C code

Posted: Wed Mar 01, 2023 12:22 pm
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.

Re: Using C code

Posted: Wed Mar 01, 2023 6:12 pm
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.

Re: Using C code

Posted: Wed Mar 01, 2023 6:41 pm
by medelec35
Hello.
You can find out about string functions on the Wiki here.