Cardbox > Forums > Macros and Programming > "Returning value from extrenal VBScript"
Returning value from extrenal VBScript
How to get the data back from an external VBScript |
Posted By | Post |
---|---|
cristoayre | 7-Feb-2015 17:51 I couldn't get a macro to run For..loops, so I transfered the data to an external file. That runs fine via CMD, and MsgBox showed the file data I was expecting ... but I can't get that data back into the main script. The external script has its data in a variable called "FileName" Back in main program, I tried: MsgBox("D" & data) 'D and F simply show if result was Data variable of FileName variable and even .. MsgBox (InPics) Here are the two scripts in case I've made a "boo-boo" somewhere else! >>> Set recs=Database.AllRecords If IsObject(recs) Then MsgBox("D" & InPics) FileName="pic_file.txt" >>> For Each f in my_img 'MsgBox(FileName) What's happening: When the photographer's finished, (and prints made from "Prints" folder), the prompt is clicked, and the external script then gets the filenames of the photos printed from folder - which it saves in the format "filename.jpg, *" - then empties the folder (and returns FileName) to script again. The main script then changes the "*" to the "key" found in that database record before writing it out to the text file something like "filname1.jpg,1007" "filename2.jpg,1007" etc But it's getting that data back from external script that's proving the bug!! |
bert | 7-Feb-2015 19:16 Write it by the external script to a file or use the clipboard for reading it |
cristoayre | 7-Feb-2015 19:17 ... suddently I thought "What about passing "key" variable to external program, and running the second half of the program there, (ie create the string directly, and write the file out). But now - HOW DO I PICK UP THE DATA SENT TO THE EXTERNAL SCRIPT?? |
cristoayre | 7-Feb-2015 19:20 Write it? I know JS script has "document.writeln", so something similar? (Something to research now I've got a hint) Did wonder about copy / paste, but seems to be excessively complicated for the simple task in hand |
cristoayre | 7-Feb-2015 19:35 Just tried fso.Write FileName. It came back with Object Required |
cristoayre | 8-Feb-2015 10:17 Solved it! Found that Cardbox can only send one set of variables to external script, and the latter is picked up by part of the Wscript. So here's what I've got: Set data=ActiveRecord.Fields("KEY") Run "C:\Users\Chris Brown\Desktop\PhotoBooth\ClearPrint.vbs", data ** If I try to send (....vbs", data id) it throws an error And in the second script: key=myArray(0) This might help someone else. Oh, I also found you cannot use a macro to pick up data from a Merge field. So I had to insert a dummy field, set it to 1 square wide, and set background/font to white. Still shows as little yellow triangle on main page, but small point. |
bert | 8-Feb-2015 11:20 A merge field does not exit in Cardbox. Please read the manual before you write about things which are perhaps not possible ;-) |
cristoayre | 8-Feb-2015 19:01 Sorry, Bert. I think we were at cross-purposes here. I had set up a merge block to contain {Photo_URL}/{Record} but when I tried to get the macro to read the data from the {Record} part, it couldn't do it. So I had to change the design of page slightly to put a RECORD field onto the page itself, hidden as described, and then the macro was able to find the data. Suppose it stands to reason really. The merge is only showing data whereas the field is showing data relating to that particular record. |