Source language: Translate to:

FileCopy

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

FileCopy

Postby dickvanrijn » Sun Feb 04, 2007 2:04 pm

when I start a pub the first time the command filecopy is working fine! But the next attempt in the same session i get an error "access denied"
Please a hint! Thanks! Dick
User avatar
dickvanrijn
 
Posts: 15
Joined: Thu Feb 01, 2007 10:42 am
Location: Germany

Postby Gaev » Sun Feb 04, 2007 2:16 pm

Dick:

Welcome to the forum ...

Perhaps you can post (here) the exact command from your pub ... and if the command parameters contain [variables], you might want to check that the values associated with these [variables] are what you expect them to be ... by coding something like ...
Code: Select all
AlertBox "source" "[srcfile]"
AlertBox "target" "[tgtfile]"
... immediately before the FileCopy command ... assuming [srcfile] and [tgtfile] are the variables you are using with the FileCopy command.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

FileCopy

Postby dickvanrijn » Sun Feb 04, 2007 2:28 pm

Thanks for your response!
here is my code:
If "[db_update]" "=" "true"
MessageBox "" "Dateien kopieren und Update DB?" "ja|nein" "[jein]"
IF "[jein]" "=" "1"
FolderBox "Select a Folder:" "[folder]"
SetVar "[path]" ""
SetVar "[i]" "1"
While "[i]" "<=" "[ItemElements]"
.werden einzeln gespeichert
ExtractFileName "[item[i]]" "[satz[i]]"
.AlertBox "[item[i]]" "[folder]"
FileCopy "[item[i]]" "[folder]"
Math "[i]+1" "" "[i]"
EndWhile
EndIf
. GosUb "db_update"
EndIf
EndIf
GotoPage "MM"
-----
when the alertbox is active (without the dot) it gives me the right directory and the right files. The contents of all variables are correct.
User avatar
dickvanrijn
 
Posts: 15
Joined: Thu Feb 01, 2007 10:42 am
Location: Germany

FileCopy

Postby dickvanrijn » Sun Feb 04, 2007 2:32 pm

I´ve made compiled version! Surprise, surprise...no problem!
User avatar
dickvanrijn
 
Posts: 15
Joined: Thu Feb 01, 2007 10:42 am
Location: Germany

Postby Gaev » Sun Feb 04, 2007 4:15 pm

Dick:
I´ve made compiled version! Surprise, surprise...no problem!
... that would make one lean towards a suspicion of "some kind of defect in NeoBook" ... but perhaps you can answer the following ...

a) WHen you ran it in Design Mode, did you use the option of ...

- Run (This Page) F8
- Run (from Start) F9
- Run (from this Page) F10

b) each time you invoked this routine, did you pick the same [folder] ... or a different one ?

c) you might also post (here) the exact values of [item1], [item2] etc. ... and [folder]
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

FileCopy

Postby dickvanrijn » Mon Feb 05, 2007 4:45 am

Hi Gaev, thanks for the response!
as you might think, I´m a novice in programming. But programming makes me fun and somtetimes confused!
I´ve read your hints, but I had no succes. So I rewrote my code and as far I´ve noticed it´s working good. The new code is here:


If "[CurDir]" "=" "H:\Bilder_neu\"
MessageBox "" "Dateien verschieben?" "ja|nein" "[jein]"
IF "[jein]" "=" "1"
FolderBox "Select a Folder:" "[folder]"
SetVar "[i]" "1"
While "[i]" "<=" "[ItemElements]"
.werden einzeln gespeichert
FileCopy "[item[i]]" "[folder]"
FileErase "[item[i]]"
Math "[i]+1" "" "[i]"
EndWhile
EndIf
.für update
SetVar "[CurDir]" "[folder]"
EndIf
GosUb "db_update"
GotoPage "MM"
User avatar
dickvanrijn
 
Posts: 15
Joined: Thu Feb 01, 2007 10:42 am
Location: Germany

Postby Gaev » Mon Feb 05, 2007 6:00 am

Dick:
So I rewrote my code and as far I´ve noticed it´s working good.
... that is all that matters.

Looking at the change you made in the second posted routine ... and your earlier comments about not working the second time around ... but OK when compiled ... I am guessing that your earlier problem might have been about your selection of the [folder] ... remember that you can't FileCopy a file to its same location.

While your code is perfectly correct, you might note that NeoBook's Loop/EndLoop command facility will save you some typing over the While/EndWhile block ... so ...
Code: Select all
SetVar "[i]" "1"
While "[i]" "<=" "[ItemElements]"
.werden einzeln gespeichert
FileCopy "[item[i]]" "[folder]"
FileErase "[item[i]]"
Math "[i]+1" "" "[i]"
EndWhile
.. can be done with ...
Code: Select all
Loop "1" "[ItemElements]" "[i]"
    .werden einzeln gespeichert
    FileCopy "[item[i]]" "[folder]"
    FileErase "[item[i]]"
EndLoop


Yes, programming (of the NeoBook scripting kind) can be lots of fun !!!
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

FileCopy

Postby dickvanrijn » Tue Feb 06, 2007 5:11 am

thank you guys!
User avatar
dickvanrijn
 
Posts: 15
Joined: Thu Feb 01, 2007 10:42 am
Location: Germany


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests