# Variable Greater Than Variable...?

**URL:** <https://the.fmsoup.org/t/variable-greater-than-variable/2514>\
**Category:** Questions\
**Tags:** scripting\
**Created:** [October 8, 2021, 8:03am UTC](https://the.fmsoup.org/t/variable-greater-than-variable/2514 "2021-10-08T08:03:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harry](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@Harry](https://the.fmsoup.org/u/Harry)\
**Post date:** [October 8, 2021, 8:03am UTC](https://the.fmsoup.org/t/variable-greater-than-variable/2514/1 "2021-10-08T08:03:50Z")

</div>

Hi There Soupers! I hope you can help... I'm going around in a circle.

I have a script that collects a set of data by User input on a Filemaker UI screen. These are held in variables and those are then entered as a Record in another table.

Within this script, there is a Loop function. I create $count=0 and then Set $count=$count+n' everytime I loop successfully. I use 'Exit Loop IF = $count\>=$total' to jump out of the loop and exit the script.

It doesn't work. And I have little hair left to pull. In the Data Viewer, I watch $total sit at '12', then $count goes '6', then '12' then '18' etc. through to about 72 then drops out of the loop and exits.

Baaah!

If $total is '6', I can set 'n' to 1 through 6 and it exits, but the moment it goes over, it just runs through about 7 records then exits. I don't know what I'm doing wrong.

I built a global field to hold the total in, to run a variable comparison against and get a similar result.

Can anyone help me please?

Thank you!

---

<div class="post-metadata">

**Author:** ![Harry](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@Harry](https://the.fmsoup.org/u/Harry)\
**Post date:** [October 8, 2021, 8:07am UTC](https://the.fmsoup.org/t/variable-greater-than-variable/2514/2 "2021-10-08T08:07:05Z")

</div>

![Worksorder_Script_Screen_Grab](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/9/9b96078879d7b3848c4ef80be68dd0835cac01d1.jpeg)

Here's a screengrab of the code i wrote.

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [October 8, 2021, 8:19am UTC](https://the.fmsoup.org/t/variable-greater-than-variable/2514/3 "2021-10-08T08:19:35Z")

</div>

When you get an input from a custom dialog the input will be stored as text. When you are testing the value of $total you use GetAsNumber( $total ) to ensure that it does a number comparison and not a text comparison.

and welcome to the Soup!

---

<div class="post-metadata">

**Author:** ![Harry](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@Harry](https://the.fmsoup.org/u/Harry)\
**Post date:** [October 8, 2021, 2:23pm UTC](https://the.fmsoup.org/t/variable-greater-than-variable/2514/4 "2021-10-08T14:23:37Z")

</div>

ehhhhhflick!

Text / Number! That's why '=' works, but greater than and less than don't!!! Crikey crikey.

I'll run some testing; THANK YOU, Malcolm! Have a great weekend!

---

<div class="post-metadata">

**Author:** ![Kirk](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/kirk/32/2197_2.png) [@Kirk](https://the.fmsoup.org/u/Kirk)\
**Post date:** [October 10, 2021, 3:49am UTC](https://the.fmsoup.org/t/variable-greater-than-variable/2514/5 "2021-10-10T03:49:23Z")

</div>

You are always better served by a greater than or equal to in these loops. That is because of your found count comes out as zero, and your increment value is 1 or greater, the loop will never end as the equal will never evaluate as true.
