trouble using a string-array variable with EXIST?

nnCron and nnCron LITE discussion

trouble using a string-array variable with EXIST?

Postby alexanjo » Fri, 16 Jun 2006, 03:08

I have the following file:

C:\Program Files\Azureus\saved_files\dn2006-0615.mp4

If I test for its existance this way:

S" C:\Program Files\Azureus\saved_files\dn2006-0615.mp4" EXIST?

The result is true (-1).

If I test for its existance this way:

CREATE file_path 256 ALLOT
S" C:\Program Files\Azureus\saved_files\dn2006-0615.mp4" file_path PLACE
file_path COUNT EXIST?

the result is false (0).

If I compare these two file-path strings:

file_path COUNT S" C:\Program Files\Azureus\saved_files\dn2006-0615.mp4" COMPARE 0=

the result is true, indicating they are identical.

Why, then, does EXIST? produce a false-output with the string-array variable, file_path?

Jordan
alexanjo
 
Posts: 19
Joined: Tue, 22 Nov 2005, 01:57

Postby Valery_Kondakoff » Fri, 16 Jun 2006, 05:34

Hmm... It seems you are doing smthng wrong. Here is my test example, copied directly from nnCron console:
nnCron. v 1.91 Build 1083 21.03.2006
Copyright (C) 2000-2006 nnSoft. email:nemtsev@nncron.ru
S" C:\AUTOEXEC.BAT" EXIST? .
-1 Ok
CREATE TEST_ARRAY 256 ALLOT
Ok
S" C:\AUTOEXEC.BAT" TEST_ARRAY PLACE
Ok
TEST_ARRAY COUNT TYPE
C:\AUTOEXEC.BAT Ok
TEST_ARRAY COUNT EXIST? .
-1 Ok
TEST_ARRAY COUNT S" C:\AUTOEXEC.BAT" COMPARE 0= .
-1 Ok
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

troublesome task definition

Postby alexanjo » Fri, 16 Jun 2006, 20:25

Yes, I must be doing something wrong...

Can you please have a look at it?

Jordan

Below is the task definition that gives "strings are the same" and "file does not exist":

NoActive
AsLoggedUser
CREATE file_path 256 ALLOT
0 VALUE day_shift
Action:

\ if DN!'s mp4-RSS-feed is current and downloaded play it

S" C:\Program Files\Azureus\saved_files\dn" file_path PLACE
Year@ N>S file_path +PLACE
S" -" file_path +PLACE
Mon@ 10 < \ is month-date less-than 10?
IF
0 N>S file_path +PLACE \ place zero in-front of subsequent month-date
THEN
Mon@ N>S file_path +PLACE
Day@ day_shift + 10 < \ is day-date plus day_shift less-than 10?
IF
0 N>S file_path +PLACE \ place zero in-front of subsequent day-date
THEN
Day@ day_shift + N>S file_path +PLACE
S" .mp4" file_path +PLACE
MSG: "%file_path COUNT%"

file_path COUNT S" C:\Program Files\Azureus\saved_files\dn2006-0616.mp4" COMPARE 0=
IF MSG: "Strings are the same"
ELSE MSG: "Strings are different"
THEN

file_path COUNT EXIST?
IF MSG: "file exists"
ELSE MSG: "file does not exist"
THEN
alexanjo
 
Posts: 19
Joined: Tue, 22 Nov 2005, 01:57

Postby Valery_Kondakoff » Fri, 16 Jun 2006, 23:35

Your example works as expected. The only two things, that I can recommend:

1) If you like to add a string "0" to an existant string use 'S" 0" +PLACE' instead of '0 N>S file_path +PLACE'

2) Look at this answer in the docs ( http://www.nncron.ru/help/EN/add_info/f ... htm#n_to_s ) for an example how to pad zeroes to your 'numerical' strings...
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

Postby alexanjo » Sat, 17 Jun 2006, 01:33

Valery:

Thanks for the 'numerical' string tips.

My problem is that the the example I give does NOT work as expected!

What is really odd is that

file_path COUNT S" C:\Program Files\Azureus\saved_files\dn2006-0616.mp4" COMPARE 0=

returns true

and

S" C:\Program Files\Azureus\saved_files\dn2006-0616.mp4" EXIST?

returns true, but

file_path COUNT EXIST?

returns false when the task (in my previous post) runs!

Really confused....

Jordan
alexanjo
 
Posts: 19
Joined: Tue, 22 Nov 2005, 01:57

Postby alexanjo » Sat, 17 Jun 2006, 01:55

Do you think my problem might have something to do with a difference between running the code as a task and running the code, line-by-line, in the nnCron console?

In the console it works, as expected, but when it runs as a task, the stated problem occurs...

Jordan
alexanjo
 
Posts: 19
Joined: Tue, 22 Nov 2005, 01:57

Postby Valery_Kondakoff » Sat, 17 Jun 2006, 08:19

No. I'm pretty sure the mistake is caused by an mistype in file name or smth like this. Just test this task. Does it work?

#( test_strarray
NoActive
AsLoggedUser
CREATE file_path 256 ALLOT
Action:
S" C:\Program Files\Azureus\saved_files\dn" file_path PLACE
Year@ N>S file_path +PLACE
S" -" file_path +PLACE
Mon@ S>D <# # # #> file_path +PLACE \ place zero in-front of subsequent month-date
Day@ S>D <# # # #> file_path +PLACE
S" .mp4" file_path +PLACE
MSG: "%file_path COUNT%"

file_path COUNT S" C:\Program Files\Azureus\saved_files\dn2006-0617.mp4" COMPARE 0=
IF MSG: "Strings are the same"
ELSE MSG: "Strings are different"
THEN

file_path COUNT FCREATE
PAUSE: 1000

file_path COUNT EXIST?
IF MSG: "file exists"
ELSE MSG: "file does not exist"
THEN
)#


If it works - examine carefully the file names in C:\Program Files\Azureus\saved_files\
CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia

is there no end to this wierdness?

Postby alexanjo » Sun, 18 Jun 2006, 05:12

Valery:

Thanks for your 'test_strarray' task.

Placed it into the nncron.tab file and started the task.

Here are the msgbox outputs:

'rc.exe'

'strings are the same'

'file does not exist'

and the filename created is:

"C:\Program Files\Azureus\saved_files\dn2006-0615.mp4"

And here is the date the task ran:

CUR-DATE DATE>S TYPE
17-06-2006 Ok

Is there no end to this wierdness?

Is the problem that the variable 'file_path' is also used in my many other tasks spread-over three .tab files, in addition to your 'test_strarray' task?

Jordan
alexanjo
 
Posts: 19
Joined: Tue, 22 Nov 2005, 01:57

a clue

Postby alexanjo » Sun, 18 Jun 2006, 05:29

Valery:

After removing the two other mentioned task files via 'nnCron: Options' and restarting nnCron, your test_strarray' task ran as expected!

Why are multiple uses of a string array variable (in this case, 'file_path') in different .tab files causing all the trouble?

Jordan
alexanjo
 
Posts: 19
Joined: Tue, 22 Nov 2005, 01:57

Postby Valery_Kondakoff » Sun, 18 Jun 2006, 10:02

CU
VK
User avatar
Valery_Kondakoff
Site Admin
 
Posts: 769
Joined: Thu, 01 Jul 2004, 20:49
Location: Moscow, Russia


Return to nnCron forum (English)

Who is online

Users browsing this forum: No registered users and 0 guests

cron