Append/New/Edit Macro Function for new Compo (new/copied)

A forum where Flowcode v6 user created components can be shared, discussed and reviewed.

Moderator: Benj

Post Reply
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Append/New/Edit Macro Function for new Compo (new/copied)

Post by Rudi »

Hi,

i watched Benj's Video

http://www.matrixmultimedia.com/mmforum ... 58&t=12735

...after i copy properties from a Component for the new..
is it possibel to edit/change the macro function by user for a change, a append or a remove.

Example:
if i create a new "RS232" compo and copy the properties from RS232 to the new Component, can i change the
Macro Function "ChangeHWBaud"? ( can i see the Flowchart from this macro function and can i edit/change, append or remove code / events ? )

is this by doing "Customs Code" ?
example:
ChangeHWBaud(NewHardWareBaud)

ok..so my next question is where i can found the define in dies Macro for for the "ChangeHWBaud"?
( where i make my own for the new? )
..

i try to understand from 0 to finnish a new component how i must go on to create a new component,
at waypoint zero ...;-) ?..

so i try at first time like the video, to copy a component and added function.. this i understand and the conzept of FC is fantastic,
i would know, how i can add a new function that FC will compile the code right, Is there a Api description availabel or description how FC works append code or how customs code must be?

I read the C Code ...
example from the ChangeHWBaud..
in Macro stands:

Code: Select all

// Call Component Macro
// Call Component MAcro: RS232::ChangeHWBaud(9600)
FCD_047b1_RS232__ChangeHWBaud(9600);

Where is the define from this Macro Code "FCD_047b1_RS232__ChangeHWBaud() ?
Is it possible to edit? ( how and where i make my own for the new? )




Thank you!

Best wishes!
Rudi
;-)

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by Jordy101091 »

If you have copied the properties of a component into your own properties, and you want to reflect the changes that you have made on the "copied" properties to the component properties you have copied from then you need to use the simulation macro to do this.
The function I always use is the Component::Property -> CopyValue

You do not have to use any costume code.
the will to learn, should not be stopped by any price

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by Rudi »

Jordy101091 wrote:If you have copied the properties of a component into your own properties, and you want to reflect the changes that you have made on the "copied" properties to the component properties you have copied from then you need to use the simulation macro to do this.
The function I always use is the Component::Property -> CopyValue

You do not have to use any costume code.

Hi Jordy -
ty for your tip..
i have read your Vinculum 1 USB Host Controller thread -
i would make a same Compo but for The Pic24FJGB106 (Support USB HOST ) and would make a CDC CLASS SLAVE for communication with a USB Modem..
So i get on by waypoint Zero ;-)

i have try benj's video and the doing was very good to see at video... and i have finnsih all well..
but if i start with no compo as "template.."
I do not know how i start with an empty Compo...and what to do step by step function and code to this..
i have see the Projekt explorer .. Events..
I see the Groups Components and the Events ..
i see the Groups Connection and the Events.. and so on..

i have think by´myself, if i start to make a new compo,
example..
the compo must ...connect a pin...
where do i tell FC that must do a connect a pin.. ( in properties later then can change.. i think the same way like in the video )
but for waypoint 1 i do not know.. what must i do at First..
the next steps will go on - i am sure - i am very interested in FC - and will learn this..
i need a ..."way" ;-)

Ty for your Time and Help!!!
Best wishes!
Rudi
;-)

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by Jordy101091 »

maybe this would help you a little bit.

http://www.matrixmultimedia.com/mmforum ... 58&t=14592
the will to learn, should not be stopped by any price

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by Rudi »

Hi,

A question:
If i make a new Macro in Project explorer, and i set te Return to Type "String", the return String is set automatic to String[20].
can i set the size by myself ? because the Size of Return ( String[20] ) is fixed..
If i try to edit the return String, the Variable Name is grey.....
..
TY
Best wishes
Rudi
;-)

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by Jordy101091 »

Then there is no way to change the return variable size.
You would have to ask the the members of the MM team to try and help you.

Regards Jordy
the will to learn, should not be stopped by any price

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by Rudi »

Jordy101091 wrote:Then there is no way to change the return variable size.
You would have to ask the the members of the MM team to try and help you.

Regards Jordy

Thank You Jordy!...

..is this a future or a bug ;-)
;-)


ah..
i allways want go on and allways must stop again..
;-)

ok....

Dear MM Team ;-) ;-) ;-)
*****************************

is this Return ...Variable of String fix as a Constant with fix size of 20 or is it possible to change the size by FC User ..
please do not answere with " i can make as char...and then build the string by myself ;-)) ".. this will be the "plan B"...for a makro of a "stringbuilder".....

.. i really want this return function as string like it is.. can you please say me, how i can change the size?..why is this fixed to size of 20 ?
..
;-)

best wishes!
Rudi
;-)

User avatar
SteveM
Posts: 55
Joined: Tue Mar 25, 2014 2:09 pm
Has thanked: 28 times
Been thanked: 65 times
Contact:

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by SteveM »

Hi Rudi,

Generally speaking, you shouldn't have any problem using the Strings the way that you want to. The given size only sets a minimum size for the String in order to reserve some memory inside the chip. If your String grows longer, extra space will automatically be allocated so that the String can grow. If the String is shorter than the allocated space, it will use "zero termination" - a character with ASCII value zero that marks the end of the string (but the memory allocated does not change in this case). All of the built-in string functions, such as Length$(), Right$(), Mid$() etc., will correctly recognise the real length of the string if has become longer or shorter than 20 characters.
Having said that, I will add your report to our task list, as there may be times when using very long strings when it is more efficient to reserve memory in advance rather than have it requested in small increments each time the length changes.

The main time that you may need to be more careful is when you are accessing the String contents using an array index (e.g. 'my_string[15]'). Flowcode will return an error if you try to read an index that is outside the memory reserved for the string. Something to watch for here is that indexing by a variable (e.g. my_string[index]) checks the string length while the code is running, whereas using a literal number ('my_string[5]'), checks the string length before compiling - so the literal number version might show a blue error in the calculation window if the initial allocation of 20 characters is too small.
If the String is 'zero terminated', and so smaller than the memory allocation, you might also get strange results if there are characters after the terminating 'zero' that you look up by index.
The safest thing to do in both cases is to use the Length$() function to find the true string length at the start of an operation, and use this value to ensure that indexes are always within range.

Here's a quick pseudo-code example to show how the indexing would work in practice...

Code: Select all

NEW_VARIABLE:  my_string[20]   (begins with the default allocation).
my_string = "Wow, this is a really long string that wouldn't fit into twenty characters."
Length$(my_string)  -->  114  (String now has 114 bytes of memory)
my_string[50]       -->  ERROR:  the literal number '50' is less than the original allocation of [20] at compile time.
index = 113
my_string[index]    -->  46   (the ASCII code for '.' - the last character.  OK this time because the index is a variable)
index = 114
my_string[index]    -->  ERROR: Index out of range  (beyond the allocated memory)
my_string = "Hello"
Length$(my_string)  -->  5   (Still 114 bytes of memory reserved, but Flowcode knows that 'o' is the last character).
my_string[4]        -->  111  (ASCII code for 'o')
my_string[5]        -->  0    (zero = End of string terminator, data beyond this point is unreliable)
index = 113
my_string[index]    -->  46   (ASCII for '.'  - this value is data remaining from the old 'long' version of the string.  It is after the 'zero' terminator, so not truly part of the string)
Best regards,
Steve.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by Rudi »

SteveM wrote:Hi Rudi,

Generally speaking, you shouldn't have any problem using the Strings the way that you want to. The given size only sets a minimum size for the String in order to reserve some memory inside the chip. If your String grows longer, extra space will automatically be allocated so that the String can grow. If the String is shorter than the allocated space, it will use "zero termination" - a character with ASCII value zero that marks the end of the string (but the memory allocated does not change in this case). All of the built-in string functions, such as Length$(), Right$(), Mid$() etc., will correctly recognise the real length of the string if has become longer or shorter than 20 characters.
Having said that, I will add your report to our task list, as there may be times when using very long strings when it is more efficient to reserve memory in advance rather than have it requested in small increments each time the length changes.

The main time that you may need to be more careful is when you are accessing the String contents using an array index (e.g. 'my_string[15]'). Flowcode will return an error if you try to read an index that is outside the memory reserved for the string. Something to watch for here is that indexing by a variable (e.g. my_string[index]) checks the string length while the code is running, whereas using a literal number ('my_string[5]'), checks the string length before compiling - so the literal number version might show a blue error in the calculation window if the initial allocation of 20 characters is too small.
If the String is 'zero terminated', and so smaller than the memory allocation, you might also get strange results if there are characters after the terminating 'zero' that you look up by index.
The safest thing to do in both cases is to use the Length$() function to find the true string length at the start of an operation, and use this value to ensure that indexes are always within range.

Hi Steve,
ok.. i can go forward...ty for your service and time.
i wounder me, because the TYpe of Variable still can change... ..

please try this:
give it a return to string
the return will be a type of string fix with size 20
i try to change the size i edit.. and the variable name Return[20] was grey not can edit..
the why you give me now the answere - i understand..

but
^^^
i try to change.. in this moment , the type.. for a test... the type can change to ... Bool.. example.. and ok ( enter)
then in macro the return is type bool.. and .. i think size one byte ...
then edit this again ..
change the type of bool again return to string.....ok..enter
...
the array is one byte ;-/ and can not change again to the string[20]...
and must be delete.. and must create new..

so i have think why...
...


why Steve ;-)
;-)
;-)
;-)


Best wishes!!
^^^^^^^^^^^

Rudi
;-)

ok i think here is still a little bug.. but now you know how i found this..

edit..
i added a pic...

User avatar
SteveM
Posts: 55
Joined: Tue Mar 25, 2014 2:09 pm
Has thanked: 28 times
Been thanked: 65 times
Contact:

Re: Append/New/Edit Macro Function for new Compo (new/copied

Post by SteveM »

Hi Rudi,
Glad to hear that your project can move forward.
Very strange bug with the String size. I've taken a look into it and, fortunately, it seems to be only cosmetic. When tested using the calculation ".Return[19] = 32", there is no error in the calculation icon, which means that the String does still have 20 characters, even when another type was previously used. So it looks like it is just the text of the display which is not showing the array size correctly - which we will add to our 'to do ' list.

Best wishes,
Steve.

Post Reply