#1 2017-02-24 20:32:25

Antonio.Cambule
Member
Registered: 2017-02-19
Posts: 38

Howto use Function Arguments correctly in AB?

Good Evenening,

i'm trying to use a function with arguments like following, but it seems not work as expected:

Code in the function:

If "[WarningMsg]" "==" ""

  SetVar "[WarningMsg]" "\n[AValue]" "String"

Else

  SetVar "[WarningMsg]" "[WarningMsg]\n[AValue]" "String"

EndIf

Arguments in the Arguments-List: [WarningMsg] and [AValue]

----

Call from Event, somewhere else:

  // Init WarningMsg
  SetVar "[WarningMsg]" "" "String"

  ...

   if "[ValidationMessage]" "!=" ""

     AddLine "[WarningMsg]" "[ValidationMessage]"

   EndIf

   ...

Edit:
I want to input two values and append the second value to the first value using a linebreak
I expect to get the values of the variables [WarningMsg] and [ValidationMessage] values into the argument variables
[WarningMsg] and [AValue]

Last edited by Antonio.Cambule (2017-02-24 20:37:09)

Offline

#2 2017-02-24 20:58:22

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Howto use Function Arguments correctly in AB?

Hola Antonio,

I think I must to apologize... certainly this is something that may can be improved in the future, however, rigth now we can get this kind of issue when try to update an app's variable from a function, if we use the same name in some of the function's arguments.

The solution of course is to rename the function's argument, so we can get the things working as expected. I remember you ask something to me in relation with AB functions, and I forget to comment you this possible issue, then my apologizes.

Maybe until I can't do something about can be a good idea to document this into the program's help. For now, please, download and take a look at this prepared application sample, because I think you can view working what you wanted. Note how I rename the "[WarningMsg]" function's argument to be "[AWarningMsg]".

55e90s3.gif

Offline

#3 2017-02-24 21:18:26

Antonio.Cambule
Member
Registered: 2017-02-19
Posts: 38

Re: Howto use Function Arguments correctly in AB?

i see. Sure that works in this case, but you're right that needs improvement.

The idea is to provide the functions two values, one that will be extended and the other that extends, without knowing the outer variables, so that i could use AddLine for any variable i put in, and do not need to know it's global name.

So, here we are again with use of globals neutral

Offline

#4 2017-02-24 21:26:41

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Howto use Function Arguments correctly in AB?

Hello Antonio,

Antonio.Cambule wrote:

i see. Sure that works in this case, but you're right that needs improvement.

The idea is to provide the functions two values, one that will be extended and the other that extends, without knowing the outer variables, so that i could use AddLine for any variable i put in, and do not need to know it's global name.

So, here we are again with use of globals neutral

I think that, with a little of care, we can do the job (as we see in the sample application, prefixing the app's function's arguments in some well knowed way). Certainly this is not exactly a question related with global variables... I say behind the scenes is not a question like that, but how AB parse the app's and app's functions code. Anyway yes, probably I must try to look into this more deeply Antonio.

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.