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

Multi-level flow inside for loops and conditions, bug for this usage scenario - fixed #961

Closed
queyintik opened this issue Mar 9, 2021 · 4 comments
Assignees
Labels

Comments

@queyintik
Copy link

queyintik commented Mar 9, 2021

Thank you for creating TagUI. It helps me a lot in my daily work.

I just upgraded from TagUI 5 to TagUI 6 and came across the following issue in version 6.14:

I have 3 files: main.tag, flow1.tag and flow2.tag with content as follows:

main.tag:

for i from 1 to 2
 echo main: loop = `i`
 tagui flow1.tag

flow1.tag:

for j from 1 to 2
 echo \ flow1: loop = `j`
 tagui flow2.tag

flow2.tag:

echo \  flow2: A
echo \  flow2: B
echo \  flow2: C

However, when I run tagui main.tag -h, the output is as follows (which is not as expected):

main: loop = 1
 flow1: loop = 1
  flow2: A
 flow1: loop = 2
  flow2: A
  flow2: B
  flow2: C
main: loop = 2
 flow1: loop = 1
  flow2: A
 flow1: loop = 2
  flow2: A
  flow2: B
  flow2: C

Looking at the .raw file generated, a curly bracket is closed early (right after the first line of flow2.tag)

main.raw:

for i from 1 to 2
{
echo main: loop = `i`
for j from 1 to 2
{
echo \ flow1: loop = `j`
echo \  flow2: A
}
echo \  flow2: B
echo \  flow2: C
}

Not sure if there is any workaround with this issue. Thank you for your time.

@kensoh kensoh self-assigned this Mar 10, 2021
@kensoh kensoh added the bug label Mar 10, 2021
@kensoh
Copy link
Member

kensoh commented Mar 10, 2021

Hi @queyintik thanks for raising this! I confirm that you have found a bug that we didn't run into when testing the tagui step.

Let me look into this and make a patch to fix this. CC @ruthtxh

function expand_intent($script_line) { // function to handle calling of other TagUI automation scripts for reusability
if ((strpos(strtolower(trim($script_line)),'tagui ') === 0) or (strtolower(trim($script_line)) == 'tagui')) {
$params = trim(substr(trim($script_line)." ",1+strpos(trim($script_line)." "," "))); if ($params == "")
die("ERROR - filename missing for step " . trim($script_line) . "\n");
else if (!file_exists(abs_file($params)))
die("ERROR - file not found for step " . trim($script_line) . "\n");
else {$indentation_for_tagui_step = str_replace(ltrim($script_line),'',$script_line);
$expanded_intent = ""; $temp_input_file = fopen(abs_file($params),'r'); if ($temp_input_file == false)
die("ERROR - cannot open file for step " . trim($script_line) . "\n");

something needs to be changed in below line for tagui_parse.php, otherwise when a subflow is expanded, only its first line will follow the indentation depth of the parent but not 2nd line onwards

while(!feof($temp_input_file)) {$expanded_intent .= $indentation_for_tagui_step . expand_intent(fgets($temp_input_file));}
fclose($temp_input_file); return $expanded_intent;}} else return rtrim($script_line) . "\n";}

@kensoh kensoh changed the title Multi-level flow inside for loops Multi-level flow inside for loops - to check and fix a bug with this usage scenario Mar 10, 2021
@kensoh kensoh changed the title Multi-level flow inside for loops - to check and fix a bug with this usage scenario Multi-level flow inside for loops - to check and fix the bug with this usage scenario Mar 10, 2021
@kensoh
Copy link
Member

kensoh commented Mar 10, 2021

Hi @queyintik, above commit seems to solve the problem and generates correct results below. Can you help to test on different usage scenarios that you may have to see if this fix solves all such problems without causing new problems?

You and other users with this issue can download the latest copy of TagUI from here and unzip to overwrite your existing installation (please drag the folders under tagui\src to overwrite your existing installation) -

https://github.com/kelaberetiv/TagUI/archive/master.zip

In the next release, this fix will become part of the packaged zip files.

Thank you very much for spotting and reporting this bug!!

main: loop = 1
 flow1: loop = 1
  flow2: A
  flow2: B
  flow2: C
 flow1: loop = 2
  flow2: A
  flow2: B
  flow2: C
main: loop = 2
 flow1: loop = 1
  flow2: A
  flow2: B
  flow2: C
 flow1: loop = 2
  flow2: A
  flow2: B
  flow2: C

@kensoh kensoh changed the title Multi-level flow inside for loops - to check and fix the bug with this usage scenario Multi-level flow inside for loops - bug checked and fixed for this usage scenario Mar 10, 2021
@kensoh kensoh changed the title Multi-level flow inside for loops - bug checked and fixed for this usage scenario Multi-level flow inside for loops and conditions - bug fixed for this usage scenario Mar 10, 2021
@queyintik
Copy link
Author

I've updated tagui\src with the latest copy of TagUI and tried with my own flows again. The indentation bug is gone. Now it works like a charm! Thanks for helping.

@kensoh kensoh changed the title Multi-level flow inside for loops and conditions - bug fixed for this usage scenario Multi-level flow inside for loops and conditions, bug for this usage scenario - fixed May 25, 2021
@kensoh
Copy link
Member

kensoh commented Jun 18, 2021

Closing issue, change included in latest packaged release - https://github.com/kelaberetiv/TagUI/releases/tag/v6.46.0

@kensoh kensoh closed this as completed Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants