Are Formats / Windows the same thing?
When you change view, are you (programatically speaking) swithcing to a new window?
When you change view, are you (programatically speaking) swithcing to a new window?
I created a database (Photo Database) I then created a new format, which became (Photo Database #2) Cannot see a way to rename that as it's part of the same database.
I've tried various options from the manual, but none appear to allow access to that second "window"
Using macro / VBS, I want to access that second (#2) page/format, replace the record with an image from an external folder, and send format to the printer ... if I could find a way to access that record in the second window! (Should be possible to replace the field with image as you can change the data in most field via macros etc)
**I also tried recording jumping to external folder, copying to clipboard, returning to app and pasting into record ... only whilst the paste option is there, and the cursor flashes in field, it won't allow me to paste into record!! All the macro said after all this action was "Application:WindowState Normal" (Properties of field is NOT Read Only)
*** Also manual says, go to menu, load as object. Great. Apart from only showing two types,(Text and Rich Text) when you select "*.*" it loads it as data!!(ie first few lines show Exif keyword)
**** "Or you can use CTRl+R ..." only that does absolutely nothing if on view record or edit record!
As you can no doubt tell, bit frustrated with this today!
If you read the manual you could know that #2 means that you opene a database with same name a second time in your window.
So I've not actually set up a second window? Will have to experiment with that tommorrow. Still don't know why pictures won't work, and the image button mentioned in manual no longer seems to exist
I repeat: read the manual :-(
I did read manuals, and managed to get what I THOUGHT was two windows showing. (ie reporting as 2 windows under Windows menu, and 2 windows showing in workspace) However, after more research, it would seem that the "New Window" option does not actually always mean a completely 'new window' if clicked from within an existing database. It means a copy of the first window renamed to "#2" This might be programatically the same window as opposed to a second window as per example of copying from one database to another in manual! I will have to experiment, and see if using WindowNumber variable allows me to access the fields in second window (#2) To open a TRUE New Window is to open another database.
I'm also wondering if after about 10 days it might be academic anyway as the program simply doesn't like images. Try as the manual says, and insert picture as object ... but that only permits "txt" and "rtf" files. Select "*.*", and it loads it as ASCII rather than binary for images. It allows you to add images to page design, but it doesn't allow you to put pictures in records fields. Copy & Paste. Nope: Only prints ASCII again!
I thought I'd have a look at sample "PhotoArchive" database button which says something like "You can now add images to this menu. Select from menu, or use Ctrl+N" or file->import" ... except that ALL these option are greyed out, and reports the file as Read Only. (Just looked at macros, and see this demo only works if connected to an S3 account to save the images, so you can't get that running either)
Had a look at "Photos" which DOES have pictures in. Thought I'd have a look at the format to see if I'd done anything wrong, ie setting the format of the record to binary or something. But that's been set to read only, and you cannot interogate the format!
Maybe when the final free rather than paid version was released, the option to use pictures was also removed.
The window convention is a minor 'niggle' which I can get around given time. The fact that I cannot get photos to work on local machine is more worrying
I was half right, but going about it wrong way. You do need to set the format of the field to binary ... but in the format menu, this is also greyed out. Appears that the answer is to set it from the NATIVE menu. (Must remember that format views are only 'read only' versions of the native which actualy sets things)
Not tried it yet, but wanted to get back here quick before you posted to forum. I'm a bit more positive now!
There is a simple working photo example available on http://cardbox.magix.net.
Sorry. I sense I'm annoying you! Whilst they might be "very basic Cardbox things" to someone who has experience of using it, to someone who is new to the program (10 days), and also new to all things Visual Basic, it's very challenging to say the least.
**I'm in two minds about this next part now. I thought I might send you a screenshot of my progress so far:
So now =MY= challenge is to learn how to use an external script to take an image from a folder, and place into a record, and then find out how to get the external script to print a format window that's not displayed. I seem to have exhausted your help at this time, but thanks for what help you have given.
You can make a vbs script that starts a "hidden" Cardbox.
I did read the manuals ... but I'm afraid I "cram read". I went through the whole manual in one marathon 4.5hr session, so some sunk in and some didn't. Then the next day I went through the macros, and again - having learned PERL by trial and error too - some of it made sense, and some went over my head. I agree, I should really sit down and read through it SLOWLY again, but - as ever - I try to run before I can walk!
At least with PERL, if the script is wrong, you get an Internal Server Error, and can check an error log to see what's wrong. (Before you say it, I remember reading there is an option to write a log, but I think that's to record what the script's variables are set to rather than error reports) But when using the Cardbox macro, or a VBS written in a text editor, if it's wrong - simply nothing appears to happens! I actually anticipate that loud "DONG!" with an error prompt. At least that points to the line where the error is.
I heed what you say about the starting a second application of Cardbox in the background, and it's an approach I'll look at if I can't find an alternative. My current thought process is I can simply send the image directly to the record in current ActiveWindow so that it appears in that field top right - which will update the field in second format layout of that record. If "push comes to shove" I'll then simply use a macro to swap formats, and then print the ActiveWindow
Again, thanks for your patience
You missed again a first step in Cardbox Help:
So that help prompt says You can use Microsoft Script Debugger. (Will have to check that later and check it's not one of the items Microsoft now charge developers to use!)
Well, I had a go at pulling various parts from manual, and I got this. Probably a "scholbox howler" in there somewhere, but the "ReadFromFile" is still complaining. Yet to me, it looks as it is in book. And Googling the error 800A0401 says there's a syntax error. But what (Line 9 Char30)
Set fso = CreateObject("Scripting.FileSystemObject")
'' EVERY TIME, THIS RESPONDS "End of statement required ine 9 Char 30
' COPIED DIRECTLY FROM HELP FILE
Thought I'd try copy and paste from edit window. That ADDS an image rather than replace, (so have to paste, and then delete original?) Thought I'd do as manual suggests, and record a macro to see key strokes ... but of course, the right click to access commands for "LoadFromFile" etc are not available whilst recording
see a working read images example on http://cardbox.magix.net
I agree with you 100% Mary. It's a very comprehensive program, and has more 'bells and whistles' than my program actually needs at this stage. Agree too I need to study the manuals and help files line by line. But unlike learning Perl where you can see programs other people have developed, and see the inner workings, and 'pinch' lines of code to use in your own program, it's a bit more 'hidden' in terms of Cardbox and VBScript. When using PERL, (I created five websites and four stand alone programs over about 10 years) you can turn to places like Stackoverflow, or even support of web hosting company to give you pointers on where PERL/UNIX code is wrong, but since Cardbox is a much smaller community, there is less help on the net.
Please, don't read this as though I'm "knocking" you or Bert; I'm grateful for any help to guide me. I just wish it was more a case of "No, partA is wrong. What you really need to do is XYZ, and change partB to this. Find details about this on pageXX of the macro guide or Help point 999"
Bert: You suggested the Microsoft Debugger. That's now been depreciated, and only works as far as the XP software anyway. (I'm on Windows7) The other option was in Visual Studio. I might try running thro Internet Explorer to see if that has a debug option. Shame Firefox cannot support VBScript, but then I believe the latter is coded by Microsoft.
Anyway, time to look at magix.net
Perl is totally not comparable to Cardbox. Perl is developer tool. Cardbox is a user application.
Then: MS Script debugger runs in Win 7 also win 8(.1) even 64 bit. However: MS install things that disturb their own Script Debugger.
Just briefly looked through the "ImportImages" macro, which may be a starting point (Thanks) ... One point. It's initiated from a push button running a macro from WITHIN Cardbox. I need everything to be command based from an external VBScript so it happens automatically in the background. Just a case of getting my head around the "object" syntax, and then adding "xyz." name of object to start of commands shown.
Also, this reads images in sequencially, (which of course is what it's designed to do). With my database, I'm on a pre-selected record, and need to replace that image. (Simple enough: Go into Edit mode/Delete Current Photo/Load From File. Found that simply giving LoadFromFile appends it to record) May be able to shorten that sequence if read directly into images(0) or similar command.
You said I don't need the fso part. I'll remove that. (Case of 'borrowing' from another script to see if it fits) Is the syntax correct on the ReadFromFile line? It keeps failing saying that it's missing "end of statement" at char 30 (the space at end of command / start of path)
I've got it down to a flow diagram of what I need to do from the external script.
Of course, some of those are macro commands, and I shall be using the direct VBS command.
Thanks. Off to have a deeper look at the macro to see what gems I can discover
Sorry, don't want us to decend into the world of "Trolling", but when I made the analogy with PERL, I was referring to the syntax of VBScript, such as "For..Next", "If..Then..Else" loops being very similar, assigning data to variables, (var $a=1 in PERL, Set a=1 in VBS)
I understand you don't want to write another person's code. That's understandable, as if you did that for one person, where would you draw the line? (Unless you get paid for it. And I think it's good of you to devote so much time to this forum anyway) Plus, you don't learn if it's done for you.
Re the debugger, I was only going by what was written on the Microsoft site re being depreciated, and not being compatable from XP. Thanks for the insight that it will work. Can but give it a try. If it don't work, I simply uninstall.
Thanks for the code snippets. I can understand how they're working ... and they might just be the answer.
So far, I might have been working "back to front", and trying to get an external script to "push" data into Cardbox, mainly because I needed to run a DO loop - which I don't think Cardbox would like!
But in a "flash of inspiration" I'm wondering if between "img.Remove 1" and "ReadFromFile", I insert a Run command. This will then trigger the external DO loop, and pause the macro until the external script signals OK to continue. I appreciate that whilst waiting for the signal, Cardbox would be unable to do anything, but that's no real problem. If it was, I could perhaps start a second copy of Cardbox, and run the command from there. (Get one thing right first!)
Incidentally, is there a timeout limit on how long a run command will wait for the script being called to return its data?
On a tangent, I've just been doing some reading ("Great!" says Bert!) Am I correct in saying that in order to use Cardbox commands in an external script, they have to be set as CONST at the top? If that is the case, then my original script would NEVER work anyway as "cbxReadFromFile" is not one of the codes listed in the manual.
Similarly - if the above is true - there appears to be no cbxEditRecord either, so I don't think I could use an external VBScript to force a Cardbox record into edit mode either.
I did find one command that MIGHT be of use ... but couldn't find any details in help or manual:
I think between us we're getting there!
When I said "They might be ...", I wasn't being insulting to your knowledge. What I didn't express very well was that after all the runaround I've given you on this thread, and various incorrect methods I've suggested, we could have now reached a working plan and thus might / could have the solution.
Why do I think it doesn't like loops. Put it down to my coding inability at the time. I tried it a few times, and it just wouldn't work. (Just tried it again, and For..Next worked fine!!)
Timeout. You missed my point I'm afraid. I know there is the sleep command; I use that within my script in a "Do Until" loop. But - to use a similarly - when you use FTP and the server doesn't get any data for a few minutes - it closes the connection. I wondered if there might be a similar constraint when Cardbox called an external macro. If it didn't get any response within say 2mins, it would kill the process. (Indirectly, I found that scripts CAN be set to "die" after a limited time because I accidently set my wscript to quit after 1 sec when finished, so when an error did pop up, the program quit before I'd had time to read the prompt. Took me a while to get that property disabled again)
Yes, I did read the table of constants - which is how I found the cbxImageOverwriteFile which I could find nothing about. "You can use also the numbers when needed in stead of the cbx ..." Don't even know where to find the numbers, or how I'd use them. But let's not go down that road; save that for when I need them
By the way, is "arec.save=" a typo?
- arec.save without = (in first) it was right of course. Unwanted type error.
|© 2010 Cardbox Software Limited|