Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if else really missing #560

Open
PierreBrisorgueil opened this issue Oct 6, 2020 · 5 comments
Open

if else really missing #560

PierreBrisorgueil opened this issue Oct 6, 2020 · 5 comments
Labels
area/compiler Compiler issue area/parser Parser issue area/runtime Runtime issue area/syntax FQL syntax issue status/proposal New proposal type/enhancement New feature or request

Comments

@PierreBrisorgueil
Copy link
Contributor

I have about fifteen scrapings that run from a global point of view I observe that it really complicates my code.

Examples:

  • 1/ in a form, I have to fill a field only according to the presence of a scrap parameter
  • 2/ on a site, I have to change the currency only if required
  • 3/ do actions if an element exists?

really simple things, which become quite complicated ... I have to play with loops ...

LET test = INNER_TEXT(element) != $ ? 1 : 0
LET action = (
    FOR i in 1.. test
        ......
        RETURN true
)

It really complicates the job ...

are there other possibilities? or can we consider a feature in this sense?

The more I have experienced ferret for a year, the more I have to go to this kind of test for complicated sites and production usages

@ziflex ziflex added area/compiler Compiler issue area/parser Parser issue area/runtime Runtime issue area/syntax FQL syntax issue type/enhancement New feature or request status/proposal New proposal labels Oct 7, 2020
@PierreBrisorgueil
Copy link
Contributor Author

@ziflex same idea for try catch to handle exceptions :

  • For example, we work on a string, to retrieve information, sometimes the value that we want to be retrieved is optional, the scrap couldn't be stop for this exception.
  • Or we would like to test two parsing methods on the string.
  • Or we call an external API to add complementary data, we should be able to catch failed

@ziflex
Copy link
Member

ziflex commented Nov 11, 2020

I wonder if pattern matching would be better for it? We would get logical branching and keep declarative feel of the language.

@PierreBrisorgueil
Copy link
Contributor Author

hmm, that could be a solution. But what would that give for a try-catch?

Afterward, I am hesitant, for "if else" it would be consistent for ferret, but spontaneously when two friends tested ferret, they always asked first how to do an "if else".

Everyone knows "if else" everywhere, even in excel. It can be interesting for "onBoarding" to have both. If I had to keep just one I think I would stay on the "if else" for that aspect.

@PierreBrisorgueil
Copy link
Contributor Author

PierreBrisorgueil commented Dec 6, 2020

@ziflex Another use case, a form leads to the results page, it would be good to be able to exit the code with an if else, if a "no result" is displayed before a WAIT_ELEMENT of the results

(one page site)

75 lines of result treatment in this tricks to deal with it

LET testResult = LENGTH(ELEMENTS(doc, '.no-results-heading')) == 0 ? 1 : 0
LET actionResult = (
    FOR i in 1.. testResult
        ......
        RETURN DATA
)
RETURN actionResult

@ziflex
Copy link
Member

ziflex commented Apr 1, 2021

Alternative solution could be adding a support of workflow - a tree of scripts that are executed within same context where you can branch the execution flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/compiler Compiler issue area/parser Parser issue area/runtime Runtime issue area/syntax FQL syntax issue status/proposal New proposal type/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants