LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For loops

Hello.

I have a problem with a for loop. I have donloaded a html file from a
server which I intend to parse. But first I have to translate some of
the charaters in the file from html notation to normal charatcers ( e
g from Å style to åäö). My problem is that the subsequent VI get
one text for each turn in the loop ( so i get 6 copies of my html file
fed into my parser). How do prevent all but the last iteration to
reach the other VIs? I would like somethin like this:

arr=[1,2,3,4,5,6,7,8];

for i = 0 to 7
begin
arr[i]= arr[i]+1
end

(* now do something else with my data *)

BRG Anders Olme
0 Kudos
Message 1 of 5
(2,553 Views)
If the Input array size is N then only run the For Loop N-1 times.


"Anders Olme" wrote in message
news:e9be8caa.0211170036.63f8c4e3@posting.google.com...
> Hello.
>
> I have a problem with a for loop. I have donloaded a html file from a
> server which I intend to parse. But first I have to translate some of
> the charaters in the file from html notation to normal charatcers ( e
> g from Å style to åäö). My problem is that the subsequent VI get
> one text for each turn in the loop ( so i get 6 copies of my html file
> fed into my parser). How do prevent all but the last iteration to
> reach the other VIs? I would like somethin like this:
>
> arr=[1,2,3,4,5,6,7,8];
>
> for i = 0 to 7
> begin
> arr[i]= arr[i]+1
> end
>
> (* now do somethin
g else with my data *)
>
> BRG Anders Olme
0 Kudos
Message 2 of 5
(2,553 Views)
> I have a problem with a for loop. I have donloaded a html file from a
> server which I intend to parse. But first I have to translate some of
> the charaters in the file from html notation to normal charatcers ( e
> g from Å style to åäö). My problem is that the subsequent VI get
> one text for each turn in the loop ( so i get 6 copies of my html file
> fed into my parser). How do prevent all but the last iteration to
> reach the other VIs? I would like somethin like this:
>
> arr=[1,2,3,4,5,6,7,8];
>
> for i = 0 to 7
> begin
> arr[i]= arr[i]+1
> end
>
> (* now do something else with my data *)
>

Forgive me if I'm restating the basics, but the problem sounds like
there is code in the for loop that you don't want to be there. The For
loop is a r
ectangle, with an interior and an exterior. The textual for
loop you wrote above uses the begin and end key words to indicate its
interior and exterior. If you place the (* now...) code between the
begin/end, it is "inside the for loop". With LV, code inside the
rectangle is inside the for loop. So grab it and drag it outside.
Then, if it is supposed to have data flowing between it and the for
loop, wire it up.

If this is indeed the cause of your problem, you should probably visit
the manuals to make sure you don't miss auto-indexing and shift
registers as they are powerful, but sometimes confusing loop concepts in LV.

Greg McKaskle
0 Kudos
Message 3 of 5
(2,553 Views)
hmm.. Ok I got that part workning now.. The problem seems to be that even if
i clear the indicators of there contents at startup the program seems to
remeber all values from the last run. So for each time i run the program it
accumulates the same data over and over like this.

string indicator s1=1,2,3,4,5

next run i get s1=1,2,3,4,5,1,2,3,4,5

and next s1=1,2,3,4,5,1,2,3,4,5,1,2,3,4,5 and so on.

Seems that labview is not that easy afterall C++ is easier 🙂

BTG Anders olme
0 Kudos
Message 4 of 5
(2,553 Views)
You need to learn LabVIEW before you make a statement like that. You aren't
initializing your shift register before running the loop. That's why you
keep getting the last iteration in the next run. Initialization is just as
important in LabVIEW as in any other language. Even C++!!!
-Tom


"Anders Olme" wrote in message
news:ar89d3$fs99c$1@ID-48779.news.dfncis.de...
> hmm.. Ok I got that part workning now.. The problem seems to be that even
if
> i clear the indicators of there contents at startup the program seems to
> remeber all values from the last run. So for each time i run the program
it
> accumulates the same data over and over like this.
>
> string indicator s1=1,2,3,4,5
>
> next run i get s1=1,2,3,4,5,1,2,3,4,5
>
>
and next s1=1,2,3,4,5,1,2,3,4,5,1,2,3,4,5 and so on.
>
> Seems that labview is not that easy afterall C++ is easier 🙂
>
> BTG Anders olme
>
>
0 Kudos
Message 5 of 5
(2,553 Views)