How to restart a loop when EOF = True


Hi  

I have this coding  

Set recc = dbase.OpenRecordset(True, "Gate")



  

nfilenum = FreeFile  

Open "C:\Rentention Program\20080517.daf" For Input As nfilenum



  

With recc  

.MoveFirst



Do Until .EOF



Do While Not EOF(nfilenum)



If EOF(nfilenum) = True Then  

GoTo ws:  

Open "C:\Rentention Program\20080517.daf" For Input As nfilenum  

Else  

End If



  

Line Input #nfilenum, sNextLine  

merid = Split(sNextLine, ",")(0)  

merid = Replace(merid, """", "")  

branch = Split(sNextLine, ",")(1)  

branch = Replace(branch, """", "")  

trancode = Split(sNextLine, ",")(4)  

trancode = Replace(trancode, """", "")  

cardno = Split(sNextLine, ",")(10)  

cardno = Replace(cardno, """", "")  

currcode = Split(sNextLine, ",")(18)  

currcode = Replace(currcode, """", "")  

tranamt = Split(sNextLine, ",")(19)  

tranamt = Replace(tranamt, """", "")  

trandef = Split(sNextLine, ",")(22)  

trandef = Replace(trandef, """", "")  

trancomm = Split(sNextLine, ",")(25)  

trannet = Split(sNextLine, ",")(26)



  

If Mid(cardno, 9, 6) = "426351" Or Mid(cardno, 9, 6) = "433468" Or Mid(cardno, 9, 6) = "479714" Or Mid(cardno, 9, 6) = "432411" Then  

GoTo wc:  

End If



n = !Meid  

m = merid + branch  

If StrComp(n, m, vbTextCompare) = 1 Or StrComp(n, m, vbTextCompare) = -1 Then  

GoTo wc:  

Else  

connec.BeginTrans  

recc("Amt") = !Amt + trannet  

.Update  

connec.CommitTrans  

GoTo wc:  

End If



  

wc: Loop



  

ws: .MoveNext  

Loop



MsgBox "Record Successfully updated"  

End With  

End Sub



And i am trying to do is for each record in recc do full loop on nfilenum.But the problem i am facing is that when the loop in nfilenum reach EOF i dont know how make it restart back to the begining of the file.



Can any one please help me.  

Or email me [collincon@seychelles.net](/posts/bad_link/620032?url=mailto%3Acollincon%40seychelles.net)
Correct syntax is:



```
do
...
loop until ........
```

OR



```
while .......
....
wend
```
[image] dueck456:

is there an easy way to detect when new code is flashed to the device so i can reinitialize the retained variables?

below is a link to a post by [@rickkas7](/u/rickkas7) about storing retained data in a struct.

[image] dueck456:

saving a know value to eeprom jumps to mind

there is … A few things to try.


1. Use [Variable Tables](http://odetocode.com/Articles/365.aspx) instead -> maybe the import wizard prefers that?
2. Name your return fields.


Try using the following stored proc (untested .. just thinking out loud...)



```
CREATE PROCEDURE dbo.Foo
AS

    SET NOCOUNT ON

    DECLARE @ResultTable TABLE (SomeId INTEGER)

    INSERT INTO @ResultTable
    SELECT DISTINCT Id AS Identity -- Or u can rename this field to anything...
    FROM SomeExistingTableWhichHasAnIdentityField

GO

```

Try that and see if the wizard refreshes, now.


-- 


 Attempt #2 :)


Ok .. when the EF designer/wizard/whatever fails to figure out EXACTLY what my stored proc is suppose to be returning, I usually do the following :-


1. Make sure the stored procedure doesn't exist at all in the EF designer/context, etc. (You have a clean starting point)
2. Open up your stored procedure and `/* /*` comment out *EVERYTHING* after the procedure definition.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    /* 
    .... every thing in here is commented out 
    */
GO

```

Now ...
 3. Add a forced fake return in the stored proc, which (more or less) just *defines* the output structure/fields.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    SELECT 1 AS Id, 1 AS UserId, 1 AS SomeOtherId, 
        CAST('AAA' AS NVARCHAR(350)) AS Name,
        -- etc etc etc..
    /* 
    .... every thing in here is commented out 
    */
GO

```

[and then](http://www.youtube.com/watch?v=K7luMp6lb9M) ...


4. Add this stored proc to your EF designer/wizard/etc... Now the correct fields should be 'determined' by the designer. AWESOME. Yes .. the values are all hardcoded .. but that's ok (so far).
5. Once your happy that EF is now updated right, go back to your stored proc, and remove all hardcoded SELECT (which we did in the above step). Now we remove the comments which we commented out the entire real code. So you should have your original stored proc, back.


... and now EF is updated and doesn't know we've changed the plumbing of your stored proc.


win :)


does this work for ya? if response.keys: # if the list is not empty

border.opacity = 1 # needs to be reset on each trial

if response.keys[0] == ('f'):

border.pos = [-0.3, 0]

elif response.keys[0] == ('j'):

border.pos = [0.3, 0]

else:

border.opacity = 0

else:

continueroutine = fa… no i can’t, but you can look up the solution on the [hints page](http://forum.freecodecamp.org/t/freecodecamp-challenge-guide-profile-lookup/18259) if you’re ready to give up.

all you need to change is the placement of this line:

return "no such contact"

right now it’s inside the for loop (before the closing }), it needs to be outside the for loop (after the closing }) unfortunately, if using our [regular legacy update scripts there will be a reset at the end of the update](http://git.toradex.com/cgit/meta-toradex-demos.git/tree/recipes-images/images/files/library/imx6/flash_blk.scr?h=rocko#n43). so the issue will be that after the run update step it will always reset before doing the env default -a && saveenv. your proposed solution as given above will therefor update-loop (;-p). howeve… A couple of notes to get started:



> 
> .apply(literal\_eval)
> 
> 
> 


Wouldn't this be better as `map`?



> 
> I then re-create the Dask DF:
> 
> 
> ddf = dd.from\_pandas(ddf\_out, npartitions=nCores)
> 
> 
> 


`ddf_out` was already a dask dataframe, I don't know why you had to do this.



> 
> The columns in result seem to match those in metadir.
> 
> 
> 


The value of `result.columns` is taken from the meta you provided, no computing happens until you ask for it (dask is lazy in most operations). Does the ValueError exception not provide further information?


Here is a full example



```
x = ({'F9_07_PZ_COMP_DIRECT': '0',
  'F9_07_PZ_DIRTRSTKEY_NAME': 'DEBRA MEALY',
  'F9_07_PZ_COMP_OTHER': '0',
  'F9_07_PZ_COMP_RELATED': '0',
  'F9_07_PZ_TITLE': 'CHAIR PERSON',
  'F9_07_PZ_AVE_HOURS_WEEK': '1.00',
  'F9_07_PC_TRUSTEE_INDIVIDUAL': 'X'},
 {'F9_07_PZ_COMP_DIRECT': '0',
  'F9_07_PZ_DIRTRSTKEY_NAME': 'HELEN GORDON',
  'F9_07_PZ_COMP_OTHER': '0',
  'F9_07_PZ_COMP_RELATED': '0',
  'F9_07_PZ_TITLE': 'VICE CHAIR',
  'F9_07_PZ_AVE_HOURS_WEEK': '1.00',
  'F9_07_PC_TRUSTEE_INDIVIDUAL': 'X'})
df = pd.DataFrame({'a': x})
d = dd.from_pandas(df, 1)
meta = pd.DataFrame(columns=['F9_07_PZ_COMP_DIRECT', 
       'F9_07_PZ_DIRTRSTKEY_NAME',
       'F9_07_PZ_COMP_OTHER', 'F9_07_PZ_COMP_RELATED', 'F9_07_PZ_TITLE',
       'F9_07_PZ_AVE_HOURS_WEEK', 'F9_07_PC_TRUSTEE_INDIVIDUAL'], dtype="O")
d.map_partitions(lambda df: df.a.apply(pd.Series), meta=meta).compute()

```

How did I know what `meta` to use? I applied the function to the pandas dataframe - you might use a small piece of the dataframe to do this.


Some additional notes:


* it is an anti-pattern to load the data with pandas, pass to dask workers and then gather the whole result back to a pandas (in memory) dataframe, you are very unlikely to see a speedup this way and may incur a lot of overhead. You are better off loading with something like `dd.read_csv`, and aggregating or writing with dask functions too. Only `compute()` on something that will be small or not return anything (because it involves writing the output). The official examples do not use from\_pandas.
* string and dict processing are python methods, and so hold the interpreter lock (GIL) of any python function: threads will not actually run in parallel. To get parallelism, you need to run in processes, which is most easily achieved using <https://docs.dask.org/en/latest/setup/single-distributed.html>
* the distributed scheduler also gives you access to the dashboard, which has a lot of useful information to diagnose how your system is running. You can also configure a lot about its behaviour, in case you have firewall rules you need to obey. The best way to  

do it is to rename the file then force a replication from a known good server.


If it is not too  

corrupted you can do an updall -r and it will rebuild the indexes.


Try running  

nfixup.exe against it. If that doesn’t work, try ncompact -c against it.


Note: ncompact  

exists in all workstation installs. nfixup is not part of the client — you can  

copy it off a server that runs at a similar NBotes version.


Make sure to use  

the -c option with compact (ncompact -c whatever\your\file.nsf)


In case it didn’t assist you, then you may use professional recovery software <http://www.nsf.openfiletool.com/> NSF Open File Tool Unicode can be a problem, and Perl has its own quirks. Essentially, Perl creates a firewall that surrounds all Unicode I / O capabilities. You must tell Perl if the I / O path is encoded. If so, the DECODE rule for any input and / or ENCODE for any output.


Decoding converts the data from {encoding} to Perl's internal representation, which is probably a combination of bytes and code points.


The coding is just the opposite.


Thus, it is actually possible to "decode into" and "encode" up to two different encodings. You just need to say what it is. Encoding / decoding is usually done with the file I / O layer, but you can use the encoding module (distribution part) to manually convert between encodings.


 [perldocs in Unicode](https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=) does not read light.



  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

Here's an example that can help visualize it (there are many other ways).



```
use strict;
use warnings;
use Encode;


# This is an internalized string with these UTF-8 codepoints
# 
my $internal_string_1 = "\x{C7}\x{69}\x{64}\x{65}\x{6D}\x{5F}\x{15E}\x{65}\x{6E}\x{65}\x{72}\x{20}\x{48}\x{FC}\x{73}\x{6E}\x{FC}\x{20}\x{54}\x{61}\x{11F}\x{6C}\x{69}\x{70}";


# Open a temp file for writing as UTF-8.
# Output to this file will be automatically encoded from Perl internal to UTF-8 octets.
# Write the internal string.
# Check the file with a UTF-8 editor.
# 
open (my $out, '>:utf8', 'temp.txt') or die "can't open temp.txt for writing $!";
print $out $internal_string_1;
close $out;


# Open the temp file for readin as UTF-8.
# All input from this file will be automatically decoded as UTF-8 octets to Perl internal.
# Read/decode to a different internal string.
# 
open (my $in, '<:utf8', 'temp.txt') or die "can't open temp.txt for reading $!";
$/ = undef;
my $internal_string_2 = <$in>;
close $in;


# Change the binmode of STDOUT to UTF-8.
# Output to STDOUT will now be automatically encoded from Perl internal to UTF-8 octets.
# Capture STDOUT to a file then check with a UTF-8 editor.
# 
binmode STDOUT, ':utf8';
print $internal_string_2, "\n\n";


# Use encode() to convert an internal string to UTF-8 octets
# Format the UTF-8 octets to hex values
# Print to STDOUT
# 
my $octets = encode ("utf8", $internal_string_2);
print "Encoded (out) string -> UTF-8 (octets):\n";
print " length = ".length($octets)."\n";
print " octets = $octets\n";
print " HEX val = ";
for (split //, $octets) {
    printf ("0x%X ", ord($_));
}
print "\n\n";


# Use decode() to convert external UTF-8 octets to an internal string.
# Format the internal string to codepoints (hex values).
# Print to STDOUT.
# 
my $internal_string_3 = decode ("utf8", $octets);
print "Decoded (in) string <- UTF-8 (octets):\n";
print " length = ".length($internal_string_3)."\n";
print " string = $internal\_string\_3\n";
print " code points = ";
for (split //, $internal_string_3) {
    printf ("\\x{%X} ", ord($_));
}

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```

Output



```
Çidem\_Şener Hüsnü Tağlip

Encoded (out) string -> UTF-8 (octets):
   length  =  29
   octets  =  Ãidem\_Åener HÃ¼snÃ¼ TaÄlip
   HEX val = 0xC3 0x87 0x69 0x64 0x65 0x6D 0x5F 0xC5 0x9E 0x65 0x6E 0x65 0x72 0x20 0x48 0xC3 0xBC 0x73 0x6E 0xC3 0xBC 0x20 0x54 0x61 0xC4 0x9F 0x6C 0x69 0x70

Decoded (in) string <- UTF-8 (octets):
   length      =  24
   string      =  Çidem\_Şener Hüsnü Tağlip
   code points = \x{C7} \x{69} \x{64} \x{65} \x{6D} \x{5F} \x{15E} \x{65} \x{6E} \x{65} \x{72} \x{20} \x{48} \x{FC} \x{73} \x{6E} \x{FC} \x{20} \x{54} \x{61} \x{11F} \x{6C} \x{69} \x{70}

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
``` nvm, i think it might be because i was force running it. i reopened the script and it appears to work. there is no need for a program to do that. 

here are some simple steps which you can follow:

1.right click on your taskbar and choose start task manager.

2.once task manager is opened go to "processes" tab. 

3.when at the processes tab search for .exe file. (maybe in your case it will look like loop.exe or something) 

4.once you have found it. just right-click on it and hover over to "set priority" option. 

5.here are several options. the default one will be "normal" so just set that to "below normal" or "low". (i would prefer setting it to "below normal" so that it does not act strangely) 

6.it's done now restart your program and check the amount of ram it is using.

i hope this helps you. if not leave a reply and i will figure out another solution. glad to help.:)