Same code, different results

13 posts in this topic

SorryButImaNewbie 36

Today I seemed to run in to an old nemesis of mine, PDFCreator 1.7.1 . I had some problems with it in the past, and I thought that nowadays im kind of okey with it at least, but today It seems like a snippet of mine doesn't work as i intend it to. More exactly, the problem is that the last PDF isn't being renamed like the others, while I use the "same" code, and the others in the chain are good and working.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key?Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox(be advised many downloads are not working due to ISP screwup with my storage)

Share this post

Link to post

Share on other sites

SorryButImaNewbie 36

Yeah its a good time to start use functions with variable calls (never done it before really, and I too wanted to shorten my code somehow!)

@jdelaney

Thx, I never used FileMove before, probably will look into these functions , but after just checking the help file, I don't see how can I rename a file with it (also it says so in the help file, that I can and should use it to that too )

Share this post

Link to post

Share on other sites

kylomas 407

If the source and destination paths are on different volumes a copy and delete operation is performed rather than a move.

Because AutoIt lacks a "FileRename" function, use FileMove() to rename a file!

The destination directory must already exist, except using with flag value $FC_CREATEPATH (8).
For instance the combined flag $FC_OVERWRITE (1) + $FC_CREATEPATH (8) overwrites the target file and prechecks for the destination directory structure and if it doesn't exist creates it automatically.

Some file attributes can make the overwriting impossible, if this is the case look at FileSetAttrib() to change the attributes of a file.

Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

I do that because the emphasis isn't on the file creation or the automatization, but the primery goal, now is testing. (The program we use is developed by another company, and its shitty as hell ) The program is starting the PDFCreator, when I do some of the specific things (for example pay in money in to an account, its open the PDFCreator to save the invoice) so I thought if its open anyway, I might as well just go with it (since closing would mean the loss of the file, i think).

The link however seems to be very usefull, and will read up on it, but not now, maybe the weekend, (but I planed to polish my SQL). However with a COM object it maybe possible, but since I'm already done with the interface automatization... Will try out next project, if opportunity presents itself

(Master) @SmOke_N

Thats looks a bit complicated for first read, but the behind logic as long as I catch it is sound, and would achive the same result i guess, with much less character. I will read throught/analyze this at home, since I don't wanna read the help file at work, for the extent I would need to understand completly of what you are doing there, if nothing else I will learn a method and dig myself in to a few functions I haven't really used so far, so thanks (bonus XP is bonus XP )

Share this post

Link to post

Share on other sites

mLipok 627

The program is starting the PDFCreator, when I do some of the specific things (for example pay in money in to an account, its open the PDFCreator to save the invoice) so I thought if its open anyway, I might as well just go with it (since closing would mean the loss of the file, i think).

This works like a

Find Printer Named "PDFCreator"

Print document to this printer.

But is this program (as I understand a CRM or something like that), it is expected at the end of the print?

Or simply send to the printer (in this case called PDFCreator)?

In the latter case there is no problem.

You can even take a short test.

Try the run START /..../ PDFCreator, in the options, select autosave to some directory and set themselves a name but with the changing part (possibly the document sent to print names differently, eg. The next invoice number, But if the names are sent to printers always with the same title then try in PDFCreator settings as the name of the autosave add timestamp)

Try to make a printout of the CRM used in your company.

View contents of the directory.

If no PDFCreator window appears then I believe that there is no problem with the automation of the process through COM.

Provided that you can control the intervals between successive print, but rather that you can initiate a print separately?

Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post

Link to post

Share on other sites

SorryButImaNewbie 36

I know that PDFCreator can be a default printer (almost sure it is here)

I'm not sure if this programm would count as a CRM, since its only used inside he company, it's basicly allow our employees to search, add, delete, modify many things, in our databases, not only costumer realeted stuffs.

Try the run START /..../ PDFCreator, in the options, select autosave to some directory and set themselves a name but with the changing part (possibly the document sent to print names differently, eg. The next invoice number, But if the names are sent to printers always with the same title then try in PDFCreator settings as the name of the autosave add timestamp)

Try to make a printout of the CRM used in your company.

View contents of the directory.

I guess here at the first 2 rows, you want me to check if PDFCreator is the default printer? or I don't know, (sorry never used COM gates, so I may be a bit lost in it) Well If I would want to check the default printer I would just look in to a word file printing for example.

What do you mean by "Try to make a printout of the CRM used in your company." ? Print out what?

The PDFCreator is expected to pop up when I upload some money in to the account of the user (only working on the test servers with test datas so far naturaly) and the program makes an invoice of it automaticly, It tries to print it out, but I just use that PDFCreator window to instead save it to a specified directory (or folder, not sure which one is the right one to use here)

Controlling the intervals wouldn't be to much of a problem, since for every action I would know how many PDFs the Creator would want to print, also I could easly make it s that a new order doesn't start till it finishes its buisness with the documentation (I actually dp that with my program right now)

Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."