From: Rodimus_Prime on
I have a repeat statement set up, but it's not increasing a variable's total
each time it loops.
Here is my code;
LineNumber := 1
repeat while GetLine(SupplierListItems, LineNumber)<>""
CheckExistingNames := GetLine(SupplierListItems, LineNumber)
if EnteredSupplier = CheckExistingNames then
SystemMessageBox(WindowHandle, "The Supplier "^EnteredSupplier^"
Already Exists...........
GoTo(IconID@"Same")
end if
if EnteredSupplier <> CheckExistingNames then
SystemMessageBox(WindowHandle, "Yeah", "Information", 64) -- 1=OK
GoTo(IconID@"Different")
end if
LineNumber := LineNumber + 1
end repeat

No matter what I type in, it will always jump to the Different icon, if I
check the variable "CheckExisitingNames", it always contains the first line of
my variable "SupplierListItems". It doesn't want to add a 1 to the LineNumber.

I hope someone can help with this.

From: Dave C on
The way you have it, LineNumber will never get incremented. One of the
two If statements will ALWAYS evaluate true because EnteredSupplier
either equals CheckExistingNames or it doesn't. Since both If statements
contain a goTo call, the program flow leaves the repeat loop on it's
first iteration in either case, and never reaches the line of code that
increments the LineNumber variable.

It's not clear to me what exactly you are trying to achieve. If you can
provide a description of what you want the code to do, and an example of
what each variables value might be, then I will offer a suggestion on
how to code it.



Rodimus_Prime wrote:
> I have a repeat statement set up, but it's not increasing a variable's total
> each time it loops.
> Here is my code;
> LineNumber := 1
> repeat while GetLine(SupplierListItems, LineNumber)<>""
> CheckExistingNames := GetLine(SupplierListItems, LineNumber)
> if EnteredSupplier = CheckExistingNames then
> SystemMessageBox(WindowHandle, "The Supplier "^EnteredSupplier^"

> Already Exists...........
> GoTo(IconID@"Same")
> end if
> if EnteredSupplier <> CheckExistingNames then
> SystemMessageBox(WindowHandle, "Yeah", "Information", 64) -- 1=OK
> GoTo(IconID@"Different")
> end if
> LineNumber := LineNumber + 1
> end repeat
>
> No matter what I type in, it will always jump to the Different icon, if I
> check the variable "CheckExisitingNames", it always contains the first line of
> my variable "SupplierListItems". It doesn't want to add a 1 to the LineNumber.
>
> I hope someone can help with this.
>
From: Amy Blankenship-Adobe Community Expert on

"Dave C" <no(a)no.com> wrote in message
news:fnfqf5$k1r$1(a)forums.macromedia.com...
> The way you have it, LineNumber will never get incremented. One of the two
> If statements will ALWAYS evaluate true because EnteredSupplier either
> equals CheckExistingNames or it doesn't. Since both If statements contain
> a goTo call, the program flow leaves the repeat loop on it's first
> iteration in either case, and never reaches the line of code that
> increments the LineNumber variable.
>
> It's not clear to me what exactly you are trying to achieve. If you can
> provide a description of what you want the code to do, and an example of
> what each variables value might be, then I will offer a suggestion on how
> to code it.

In addition,

repeat while GetLine(SupplierListItems, LineNumber)<>""

is not efficient.

You wind up repeating the GetLine function twice every loop. I'd suggest
either doing this:

NumLines := LineCount(SupplierListItems)
repeat with LineNumber := 1 to NumLines

Or this:

repeat while CheckExistingNames := GetLine(SupplierListItems,
LineNumber)<>""

Likely in your application the speed difference won't be noticeable, but
it's a good habit to pay attention to how many function calls you're using
in repeat loops and whether they can be reduced.

HTH;

Amy


From: Rodimus_Prime on
NumLines := LineCount(SupplierListItems)
repeat with LineNumber := 1 to NumLines
CheckExistingNames := GetLine(SupplierListItems, NumLines)
if EnteredSupplier = CheckExistingNames then
SystemMessageBox(WindowHandle, "The Supplier "^Entered.....
GoTo(IconID@"Same")
end if
if EnteredSupplier <> CheckExistingNames then
SystemMessageBox(WindowHandle, "Yeah", "Information",....
GoTo(IconID@"Different")
end if
end repeat

SupplierListItems contains the lines of text captured from a text file
seperated by a "\r". EnteredSupplier is the variable that the user enters into
a control. The purpose here is to read SupplierListItems line by line, each
time, assigning the result to CheckExistingNames. At this point, it should
validate CheckExistingNames with EnteredSupplier. If what the user enters
matches the line of text from the text file, then it jumps out accordingly,
otherwise it jumps somewhere else.

I hope this helps explain things

From: Chris Forecast on
"Rodimus_Prime" <webforumsuser(a)macromedia.com> wrote in message
news:fng3gb$4r$1(a)forums.macromedia.com...
> NumLines := LineCount(SupplierListItems)
> repeat with LineNumber := 1 to NumLines
> CheckExistingNames := GetLine(SupplierListItems, NumLines)
> if EnteredSupplier = CheckExistingNames then
> SystemMessageBox(WindowHandle, "The Supplier "^Entered.....
> GoTo(IconID@"Same")
> end if
> if EnteredSupplier <> CheckExistingNames then
> SystemMessageBox(WindowHandle, "Yeah", "Information",....
> GoTo(IconID@"Different")
> end if
> end repeat
>
> SupplierListItems contains the lines of text captured from a text file
> seperated by a "\r". EnteredSupplier is the variable that the user enters
> into a control. The purpose here is to read SupplierListItems line by
> line, each time, assigning the result to CheckExistingNames. At this
> point, it should validate CheckExistingNames with EnteredSupplier. If what
> the user enters matches the line of text from the text file, then it jumps
> out accordingly, otherwise it jumps somewhere else.

Yes, but:
(a) as Dave suggested it'll always jump out and never ever reach the end
repeat.
(b) even if it didn't, it's evaluating exactly the same thing every time
round the loop.

It looks as though you're trying to determine if the text file contains
EnteredSupplier (on any line). If so, then try:

if Find(Return^EnteredSupplier^Return,Return^SupplierListItems^Return) then
-- yes
else
-- no
end if

no need for a loop at all.

Chris Forecast