#1 2017-01-14 18:04:10

fakie
Banned
Registered: 2016-10-28
Posts: 36

Variable late binding? (And the new AB compiler syntax checker)

Look at the code below.
I created two ABScript functions.
1. SetIni - to save data in localstorage using the "SetOption" supplied by App Builder
2. GetIni - to retrieve data in localstorage using the "GetOption" supplied by App Builder


Example Use:

SetVar "[I]" "3" "Number"

SetIni "Comment[I]" "[iNewComment.Value]"
SetIni "Date[I]" "[iNewDate.Value]"
SetIni "Category[I]" "[iNewCategory.ItemIndex]" 

SetVar "[iOption.Value]" "Whatever" "String"
GetIni "[iOption.Value]" "[Result]"
SetVar "[iOptionValue.Value]" "[Result]" "String"

Functions:

---ABScript---------SetIni [option] [optionvalue]
SetOption "Option" "[OptionValue]" "String"
--EndABScript---

---ABScript---------GetIni [option] [optionvalue]
SetOption "Option" "[OptionValue]" 
if "[Option]" "==" ""
   return ""
   //"GetIni-Option is blank"
endif

GetOption "[Option]" "[Result]"
// "Retrieved : [Result]"
// "GetIni-Option:[Option], value retrieved:[Result]"

return "[Result]"
--EndABScript---

Why did I create these functions?
SetIni:
If I use GetOption with a variable in first parameter, it does not work, I think binding of the variable does not happen when lower function is called.
I always find that I have to use SetVar to link Comment and I, and then use the result of that in GetOption.

GetIni
I found out with the GetIni function, that I cannot define a parameter by address, therefore still need two lines to get the job done.
If I change:

  GetIni "[iOption.Value]" "[Result]"
  SetVar "[iOptionValue.Value]" "[Result]" "String"

to 

  GetIni "[iOption.Value]" "[iOptionValue.Value]"

the value is not filled into iOptionValue.Value.



I guess it would be better for me to create my functions/procedures as java functions rather than ab functions?


This is my favourite quote.

Offline

#2 2017-01-15 15:27:13

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

Re: Variable late binding? (And the new AB compiler syntax checker)

Hello,

Honestly I am not totally sure that understand perfectly what you means. Please, can you provide me a little sample application that explains "what-you-expect" and "what-you-get"? I will take a look at that in order to fix the bug if any. Please use the Upload section of the forum or just send me a zip file to: info AT davidesperalta DOT com.

Offline

#3 2017-01-15 16:59:45

svanneste
Member
From: Paris, France
Registered: 2015-05-27
Posts: 155

Re: Variable late binding? (And the new AB compiler syntax checker)

Hello at all,

Well, @Fakie, I have tried to reproduce the issue but was unable to get the troubles because I do use another way to do the things. Passing by reference, seems to work but the usage of the Return command in ABScript, is perhaps, what is the cause of the problem (Return is for returning using JavaScript, if I recall correctly).

I am attaching my demo app if you want to try : MyApp.zip

Another elegant way could be to store an object as a sole option's line instead of multiple ones.

Offline

#4 2017-01-15 20:22:56

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

Re: Variable late binding? (And the new AB compiler syntax checker)

Hello to all,

svanneste wrote:

(Return is for returning using JavaScript, if I recall correctly).

That's correct!

svanneste wrote:

Another elegant way could be to store an object as a sole option's line instead of multiple ones.

Another possible way too is to store objects/arrays using the StrSerialize and StrUnserialize actions.

Offline

#5 2017-01-18 16:38:05

fakie
Banned
Registered: 2016-10-28
Posts: 36

Re: Variable late binding? (And the new AB compiler syntax checker)

Thanks for demo svanneste.
I got my program working, seems like I was reading old documentation, where setoption does not use a "String" as third parameter.

It was late at night, and I was rambling a bit.
Since we do not have real syntax checking in app builder, I am battling to find my bugs... Seems as if the best bet is to develop a very small bit in each .ab file, and then later add them all together.

ie. If you have a extra space in your setvar declaration, it can cause problems

  SetVar "[myvar]" "good" "string"
  SetVar  "[myvar]" "oops" "string"

I've decided to upgrade my internet explorer - so my view in appbuilder works. This does help a lot.
(I tend to forget to run the "inspect" when testing in Chrome.)


This is my favourite quote.

Offline

#6 2017-01-18 16:43:35

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

Re: Variable late binding? (And the new AB compiler syntax checker)

Hello to all,

fakie wrote:

Since we do not have real syntax checking in app builder, I am battling to find my bugs...

If you double click an action and they doesn't appear well in the action's editor, then the action's is not well formed. Anyway I will look into a possible syntax check in AB: I certainly think possible to do something about this.

Offline

#7 2017-01-18 18:29:20

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

Re: Variable late binding? (And the new AB compiler syntax checker)

Hello to all,

Here introducing the new App Builder's compiler syntax checker:

2017.6 (01/18/2017)

* Introducing the new App Builder's runtime syntax information. In combination with the App Builder's compiler syntax checker App Builder place now information about malformed actions in runtime in the integrated debugger console and others browsers' console.

* Introducing the new App Builder's compiler syntax checker. The Compiler syntax checker inform us about malformed App Builder's actions syntax when debug or build our apps. The App Builder's compilers (both visual and command line) place now in the log error messages when find some malformed action.

https://www.youtube.com/watch?v=S9Jf7DulAak

Hope this can be useful for all us!

http://getappbuilder.com/

Offline

#8 2017-01-19 17:37:45

fakie
Banned
Registered: 2016-10-28
Posts: 36

Re: Variable late binding? (And the new AB compiler syntax checker)

You're a star David!


This is my favourite quote.

Offline

#9 2017-01-19 17:39:37

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

Re: Variable late binding? (And the new AB compiler syntax checker)

Hello to all,

fakie wrote:

You're a star David!

Thanks you for your kindly words!

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.