If then else macro or input text macro

User-to-User discussion about the PhraseExpress macro programming.
Post Reply
Mamede
Posts: 27
Joined: 07 Apr 18, 13:47

If then else macro or input text macro

Post by Mamede » 07 Feb 21, 15:35

Hi Peter
I created a Form input with Grid and checked box

{#forminput -text Number -type 2 -items 1|2|3 -vals 1|2|3 -uncheckedvals 01|02|03 -rowlabels Number -rowenum {#asc 13 -variablename New line} -enum -lastenum -variablename Form input}

can i use If then else macro or input text macro to get anothers values for checked or unchecked THE SAME BOXS Above

so that in the above exemple when 1 and 2 box are checked the values will be 11 and 22 respectivly and when they are uncheked the values will be 011 and 022 respectivly
And how will be the syntax
faithfully

Mamede
You do not have the required permissions to view the files attached to this post.

Peter Stotz
PhraseExpress Expert
Posts: 923
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 08 Feb 21, 09:42

@Mamede
Yes, in principle the form input could be examined with the #check macro or the #cond macro to adjust the values accordingly.

But a very simple solution could also work with number substitution:

Code: Select all

your form input   {#settemp -name ##forminput -content {#forminput -text Number: -type 2 -items 1|2|3 -vals 1|2|3 -uncheckedvals 01|02|03 -rowlabels  -rowenum {#asc 13} -enum  |  -lastenum  | } -output}
customized values {#replace {#gettemp ##forminput} -oldtext 1|2|3 -newtext 11|22|33}
Peter

Peter Stotz
Windows 10 - PhraseExpress v15.0.81

Mamede
Posts: 27
Joined: 07 Apr 18, 13:47

Post by Mamede » 12 Feb 21, 11:03

A B C If.pxp
Thank you Peter
It works fine but like you see replace function if i modify oldtext A | B | C to -newtext B | B | -C ((( {#replace {#gettemp ##forminput1} -oldtext A | B | C -newtext B | B | -C } )))
The Macro take the checked and unchecked value
so B / -B appear in the results and for google search it get 0 results

can on modify the replace function so that it take only ALL vals results and never uncheckedvals results

faithfully

Mamede
You do not have the required permissions to view the files attached to this post.

Peter Stotz
PhraseExpress Expert
Posts: 923
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 13 Feb 21, 15:46

@Mamede
„... take only ALL vals results and never unchecked vals results“
If the unchecked letters are marked with a hyphen, you can remove the unchecked letters with the Regular Expression -\w+ from the result string:

Code: Select all

Your selection         : >{#settemp -name ##forminput -content {#forminput -text Please mark the desired options: -type 2 -items A|B|C -vals A|B|C -uncheckedvals -A|-B|-C -rowlabels  -rowenum {#asc 13} -enum   -lastenum  } -output}<
Positive selection only: >{#trim {#regexrep -text {#gettemp ##forminput} -expr -\w -repexpr }}<
Output samples:
Your selection : >A B C<
Positive selection only: >A B C<

Your selection : >-A B -C<
Positive selection only: >B<

Your selection : >-A -B -C<
Positive selection only: ><

Peter Stotz
Windows 10 - PhraseExpress v15.0.84

Mamede
Posts: 27
Joined: 07 Apr 18, 13:47

Post by Mamede » 14 Feb 21, 17:52

A B C If if a b c.pxp

Hi Peter

It works for unchecked values but extras letters appear for checked results ( A , AAA , BB ,CC )

and for replace old and news texts , ( - ) values persiste ( Do i have to put Regular Expression -\w+ for them also )

can i get the code please



Faithfully
Mamede
2021-02-14_17h33_22 PEX .png
You do not have the required permissions to view the files attached to this post.

Peter Stotz
PhraseExpress Expert
Posts: 923
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 16 Feb 21, 18:47

@Mamede
You want to reformat the original form input like this:
A → B
B → B
C → -C
AAA → BBB
BBB → BBB
CCC → -CCC
This regulation can lead to double B values for the markings
☑ A and ☑ B and/or
☑ AAA and ☑ BBB

Code: Select all

(* 20210216 • Spezielle Darstellung einer Formulareingabe
*){#form -text Changes the values of a form input into another form -width 450}{#formtext -text Forum request by Mamede »07 Feb 21, 15:35« -link http://www.bartelsmedia.com/forum/viewtopic.php?f=146&t=18470&sid=71e09c79ca751029237bae1fdd98490f -hint <b>hinweis</b>}(*
*)your form input         :  >{#settemp -name ##forminput -content {#forminput -text Please mark the desired values:: -type 2 -items A|B|C|AAA|BBB|CCC -vals A|B|C|AAA|BBB|CCC -uncheckedvals -A|-B|-C|-AAA|-BBB|-CCC -rowlabels  -rowenum {#asc 13} -enum   -lastenum  } -output}<(*
  Output: Positive selection with RegEx -\w+ and space char minimized with RegEx \h+ : *)
Positive selection only :  >{#settemp -name ##positive selection -content {#regexrep -text {#trim {#regexrep -text {#gettemp ##forminput} -expr -\w+ -repexpr }} -expr \h+ -repexpr  } -output}<
Result after Replacement:  >{#trim {#replace  {#gettemp ##positive selection}  -oldtext  A | C | AAA | CCC  -newtext  B | -C | BBB | -CCC }}<
Output samples:

your form input : >A -B C AAA -BBB CCC<
Positive selection only : >A C AAA CCC<
Result after Replacement: >B -C BBB -CCC<

your form input : >A B -C AAA BBB -CCC<
Positive selection only : >A B AAA BBB<
Result after Replacement: >B B BBB BBB<

your form input : >-A -B -C -AAA -BBB -CCC<
Positive selection only : ><
Result after Replacement: ><

your form input : >A -B C AAA BBB -CCC<
Positive selection only : >A C AAA BBB<
Result after Replacement: >B -C BBB BBB<

your form input : >-A B C AAA -BBB CCC<
Positive selection only : >B C AAA CCC<
Result after Replacement: >B -C BBB -CCC<

Peter Stotz
Windows 10 - PhraseExpress v15.0.84

Mamede
Posts: 27
Joined: 07 Apr 18, 13:47

Post by Mamede » 20 Feb 21, 18:24

Thank you so muchPpeter

so when i create two imput , i name the first one forminput1 and the second one forminput2 , so i can get :

My selection A -B -C AAA -BBB -CCC<
Positive selection only : >A AAA<
Result after Replacement: >B BBB<

My selection D -E -F DDD -EEE -FFF<
Positive selection only : >D DDD<
Result after Replacement: >D DDD<


But how to formulate the code so that i can get 1 ) My selection ,2) Positive selection only ,3 )the Result after Replacemen of the two imputs in the same line = like that one :

My selection : A -B -C AAA -BBB -CCC< D -E -F DDD -EEE -FFF<
Positive selection only : >A AAA< >D DDD<
Result after Replacement: >B BBB< >D DDD<

faithfully
2021-02-20_18h11_43.png
A B C If if if ;; a b C.pxp
Mamede
You do not have the required permissions to view the files attached to this post.

Peter Stotz
PhraseExpress Expert
Posts: 923
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 21 Feb 21, 12:03

@Mamede
"how to formulate the code so that I can get [outputs 1 and 2] in the same line..."
Assign the form inputs and format changes to temporary variables: #settemp ...
You can then use these variables with #gettemp ... as you like:

Code: Select all

{#settemp -name ##Forminput1 -content {#forminput -text 111 -type 2 -items A|B|C|AAA|BBB|CCC -vals A|B|C|AAA|BBB|CCC -uncheckedvals -A|-B|-C|-AAA|-BBB|-CCC -rowlabels  -rowenum {#asc 13} -enum   -lastenum  }}(*
*){#settemp -name ##Positive Selection1 -content {#regexrep -text {#trim {#regexrep -text {#gettemp ##Forminput1} -expr -\w+ -repexpr }} -expr \h+ -repexpr  }}(*
*){#settemp -name ##Result after Replacement1 -content {#trim {#replace  {#gettemp ##Positive Selection1}  -oldtext  A | C | AAA | CCC  -newtext  B | -C | BBB | -CCC }}}(*
*){#settemp -name ##Forminput2 -content {#forminput -text 2222 -type 2 -items D|E|F|DDD|EEE|FFF -vals D|E|F|DDD|EEE|FFF -uncheckedvals -D|-E|-F|-DDD|-EEE|-FFF -rowlabels  -rowenum {#asc 13} -enum   -lastenum  }}(*
*){#settemp -name ##Positive Selection2 -content {#regexrep -text {#trim {#regexrep -text {#gettemp ##Forminput2} -expr -\w+ -repexpr }} -expr \h+ -repexpr  }}(*
*){#settemp -name ##Result after Replacement2 -content {#trim {#replace  {#gettemp ##Positive Selection2}  -oldtext  D | F | DDD | FFF  -newtext  D | -F | DDD | -FFF }}}(*
*)My selection            : >{#gettemp ##Forminput1}< >{#gettemp ##Forminput2}<
Positive Selection only : >{#gettemp ##Positive Selection1}< >{#gettemp ##Positive Selection2}<
Result after Replacement: >{#gettemp ##Result after Replacement1}< >{#gettemp ##Result after Replacement2}<
Peter
Windows 10 - PhraseExpress v15.0.84

Post Reply