Basic excel script: HELP
I want a script to write to excel. But when I start with the basic it won't work.
I'm running this on Win7.
I have looked for hours, and tried diffrend commands, but result is always the same.
Can't write to cell and can't save excel file.
Script:
$xl=New-Object -ComObject Excel.Application
$wb=$xl.Workbooks.Add
$ws=$wb.ActiveWorkbook
$cells=$ws.Cells
$cells.Item(1,1).Value() = 'x'
#$ws.cells.Item(1,1).Value() = "x"
$xlWorkbookNormal = -4143
$wb.SaveAs("H:\xlstest.xlsx", $xlWorkbookNormal )
$wb.close
$xl.quit
Errors:
You cannot call a method on a null-valued expression.
At H:\_Algemeen\_Software\_MijnBeheersScript\excel.ps1:6 char:12
+ $cells.Item <<<< (1,1).Value() = 'x'
+ CategoryInfo : InvalidOperation: (Item:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At H:\_Algemeen\_Software\_MijnBeheersScript\excel.ps1:10 char:11
+ $wb.SaveAs <<<< ("H:\xlstest.xlsx", $xlWorkbookNormal )
+ CategoryInfo : InvalidOperation: (SaveAs:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Hey Mario,
If I run your script, these are the errors:
GAC Version Location
True v2.0.50727 C:\Windows\assembly\GAC_MSIL...
Exception setting "DisplayAlerts": "Unable to cast CO
M object of type 'Microsoft.Office.Interop.Excel.Appl
icationClass' to interface type 'Microsoft.Office.Int
erop.Excel._Application'. This operation failed becau
se the QueryInterface call on the COM component for t
he interface with IID '{000208D5-0000-0000-C000-00000
0000046}' failed due to the following error: Error lo
ading type library/DLL. (Exception from HRESULT: 0x80
029C4A (TYPE_E_CANTLOADLIBRARY))."
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:6 char:8
+ $Excel. <<<< DisplayAlerts = $false
+ CategoryInfo : InvalidOperation: (:)
[], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentExce
ption
You cannot call a method on a null-valued expression.
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:9 char:33
+ $Workbook = $Excel.Workbooks.Add <<<< ()
+ CategoryInfo : InvalidOperation: (Add
:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:12 char:39
+ $Worksheet = $Workbook.Worksheets.Item <<<< (1)
+ CategoryInfo : InvalidOperation: (Ite
m:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:15 char:18
+ $Excel.Cells.Item <<<< (1,1).Value2 =("UserName")
+ CategoryInfo : InvalidOperation: (Ite
m:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:16 char:18
+ $Excel.Cells.Item <<<< (1,2).Value2 = ("Path")
+ CategoryInfo : InvalidOperation: (Ite
m:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:17 char:18
+ $Excel.Cells.Item <<<< (1,3).Value2 = ("Date")
+ CategoryInfo : InvalidOperation: (Ite
m:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
The term 'Get-Openfiles' is not recognized as the nam
e of a cmdlet, function, script file, or operable pro
gram. Check the spelling of the name, or if a path wa
s included, verify that the path is correct and try a
gain.
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:27 char:14
+ Get-Openfiles <<<< | % {
+ CategoryInfo : ObjectNotFound: (Get-O
penfiles:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundExcepti
on
You cannot call a method on a null-valued expression.
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:41 char:18
+ $Worksheet.SaveAs <<<< ($LogPath)
+ CategoryInfo : InvalidOperation: (Sav
eAs:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception setting "Visible": "Unable to cast COM obje
ct of type 'Microsoft.Office.Interop.Excel.Applicatio
nClass' to interface type 'Microsoft.Office.Interop.E
xcel._Application'. This operation failed because the
QueryInterface call on the COM component for the int
erface with IID '{000208D5-0000-0000-C000-00000000004
6}' failed due to the following error: Error loading
type library/DLL. (Exception from HRESULT: 0x80029C4A
(TYPE_E_CANTLOADLIBRARY))."
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:44 char:8
+ $Excel. <<<< Visible = $false
+ CategoryInfo : InvalidOperation: (:)
[], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentExce
ption
You cannot call a method on a null-valued expression.
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:48 char:28
+ $range.EntireColumn.AutoFit <<<< ()
+ CategoryInfo : InvalidOperation: (Aut
oFit:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "Quit" with "0" argument(s): "Unabl
e to cast COM object of type 'Microsoft.Office.Intero
p.Excel.ApplicationClass' to interface type 'Microsof
t.Office.Interop.Excel._Application'. This operation
failed because the QueryInterface call on the COM com
ponent for the interface with IID '{000208D5-0000-000
0-C000-000000000046}' failed due to the following err
or: Error loading type library/DLL. (Exception from H
RESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))."
At C:\Users\Esther\AppData\Local\Temp\3c953d24-3672-4
c0f-bd8b-6bc7a30b0d23.ps1:51 char:12
+ $Excel.Quit <<<< ()
+ CategoryInfo : NotSpecified: (:) [],
MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Some of them like $Excel.Workbooks.Add, I got before, deleting the () at the end got no error
Similar Messages
-
Creating Basic Calculator Script - Needs help
I'd like to create a basic calculator script that makes doing calculations a bit easier from the command line. Normally i do:
echo "32*24" | bc
So I built a bash script that I can just type "calc 32*24":
bc << EOF
scale=4
$@
quit
EOF
And it works ok until i try to use parenthesis:
calc (1+49)/5
bash: syntax error near unexpected token `1+49'
if I use parenthesis, directly in the bc command it does ok:
bc
bc 1.06...
(1+49)/5
10
I've tried putting $@ in quotes but not luck. Looks like bash isn't transferring the parenthesis. How can I get the bash script to pass theparenthesis?Dusty wrote:This is why I always have at least one terminal in an IPython session.
+1!
I normally use a standard python instance in the same way but have just installed ipython and am having a look at it now. Looks cool! -
Script help.. find folders (title oversimplified..)
What I need:
Have list of folder names in Excel
Script uses list to find specified folders. Folders (items in list) are actually three folders deep in directory (external archive disk/dated folder/folder I want).
Script then copies folders to another location.
Basically, I have a main archive directory (Archive1). On that disk are dated folders (102013). Inside the dated folders there are anywhere from 10-20 folders.. those contain the data (study data).. and those are the folders I want. I will have a list of 50-100 data folders provided to me.. all from random dates. I dont want to manually find, then drag and drop data into new archive. I have a list.. and would like to automate this.
What I have:
Script that will find FILES.. not folders... and not in subdirectories. It does everything i need.. if I was only looking for files in one folder.
Script I have is below. If one of you kind souls would point me in the right direction, id appreciate it.
If you want to test the script below:
Make a short list in excel.. maybe just a, b, c in a column.
Create two (named mine archive and transfer) folders on your desktop.. Place three dummy files named a, b, and c in the archive folder. Run the script wile the spreadsheet is open. You will be asked to choose the archive folder. Then the transfer folder. All files from archive folder will then be copied to transfer folder. The spreadsheet will be updated to include filenames with extension in the B colum.
Script:
set studiestofind to (choose folder with prompt "Choose Archive Location")
set transferto to (choose folder with prompt "Choose the Transfer Location")
tell application "Microsoft Excel"
tell active sheet
set lastIndex to first row index of last cell of (get used range)
repeat with i from 2 to lastIndex
set tFileName to my find_filenames(get value of range ("A" & i), studiestofind)
if tFileName is not "" then -- Study Found
set r to my duplicateImage(tFileName, studiestofind, transferto)
if r is not "" then -- no error on duplicate file
set value of range ("B" & i) to tFileName
else
set value of range ("B" & i) to ""
end if
end if
end repeat
end tell
end tell
on duplicateImage(tName, iFolder, mFolder)
try
tell application "Finder" to return (duplicate file tName of iFolder to mFolder) as string
on error
return ""
end try
end duplicateImage
on find_filenames(tVal, thefolder)
--if cell begins with space or ends with space , text items of tVal return empty string, empty string added in list excludedWords
set excludedWords to {"Mini", "and", ""} -- words in Menu Item to exclude in search
set otid to text item delimiters
set text item delimiters to " "
set tWords to text items of tVal
set text item delimiters to otid
set thefolder to quoted form of POSIX path of thefolder
set myListOfWords to {}
repeat with i in tWords -- must be valid
if contents of i is not in excludedWords then set end of myListOfWords to contents of i
end repeat
if (count myListOfWords) = 1 then -- more filler i dont really understand
set i to quoted form of (tVal & ".")
-- search file name
set tpath to do shell script "cd " & thefolder & " && /usr/bin/find . -type f -maxdepth 1 -iname " & i & "*"
if tpath is not "" then return text 3 thru -1 of tpath --return name of exact match
end if
repeat with i in myListOfWords
set tPaths to do shell script "cd " & thefolder & " && /usr/bin/find . -type f -maxdepth 1 -iregex '.*[_/]" & i & "[_.].*' \\! -name '.*' "
if tPaths is not "" then
set L to paragraphs of tPaths
if (count L) = 1 then return text 3 thru -1 of tPaths -- one path found
repeat with tpath in L -- many paths found, loop each path
set isGood to false
repeat with tword in myListOfWords -- check each word of this Menu Item in tpath
if ("/" & tword & "_") is in tpath or ("/" & tword & ".") is in tpath or ("_" & tword & ".") is in tpath or ("_" & tword & "_") is in tpath then
set isGood to true
else
set isGood to false
exit repeat
end if
end repeat
if isGood then return text 3 thru -1 of tpath -- each word of this Menu Item is in name of tpath
end repeat
end if
end repeat
return ""
end find_filenamesHello
It is not hard to modify the existing script you posted so as to retrieve directories at depth 2 but I chose to rewrite it as follows because its filtering logic is very inefficient. In the current form, the script below will retrieve directories at depth 2 in the chosen folder.
The part scripting Excel is not tested, for I don't have Excel. It might fail to set the value of cell in column B when there are multiple matches in which case the script will try to set cell value to multi-line text of every found path. If it fails, we can adjust the code to work aronud it. Your original script only processes the first matched file but I thought it's better to process every matched one.
# Notes
• Filtering logic is modified so that it is now wholly processed by find(1). Also the regexp pattern is modified so that it compares the query word with string delimited by _ and . in file name.
E.g., Given query = "apple orange bananna", the original script matches these -
apple_orange_bananna.tex
apple_bananna_orange.dvi
_bananna__orange__apple.ps
_bananna._apple._orange.pdf
_orange.blueberry_bananna_apple....djvu
but not these -
apple.orange.bananna.txt
apple_.orange_.bananna.txt
apple_orange_blueberry.html
apple_orange_bananna
The new script will match all of them except for "apple_orange_blueberry.html".
• I added code to handle NFD-NFC issue of HFS+ name. HFS+ name is represented as Unicode in NFD (Normalization Form D), while name in Excel could be in NFC (Normalization Form C), in which case find(1) will not match the name whose NFD and NFC are different. This is not a issue if name is only in a-zA-Z0-9. But, e.g., any diacriticals will cause trouble if not with special treatment.
• Script will write log to file on desktop when a) some query gives no result or b) some of the matched files/folders are not copied because item with the same name already exists in the destination.
• Script will behave (mostly) the same as the original script when you set the find parameters properties in _main() as -
-- find parameters
property type : "f" -- d = directory, f = file
property mindepth : 1
property maxdepth : 1
• Currently the value in column B will be the (list of) found and copied path(s) and not the found path(s). If you need all of the found path(s) to be put in column B, switch the following statements in _main():
set value of range ("B" & i) to my _join(return, qq) -- found and copied
--set value of range ("B" & i) to my _join(return, pp) -- found
• Script is tested under OSX 10.5.8. (except for Excel scripting)
# Script
_main()
on _main()
script o
-- directories and logfile
property srcdir : (choose folder with prompt "Choose Archive Location")'s POSIX path
property dstdir : (choose folder with prompt "Choose the Transfer Location")'s POSIX path
property logf : (path to desktop)'s POSIX path & "copy_log@" & (do shell script "date +'%F.txt'")
-- find parameters
property type : "d" -- d = directory, f = file
property mindepth : 2
property maxdepth : 2
-- working lists
property pp : {}
property qq : {}
property rr : {}
-- find & copy nodes
tell application "Microsoft Excel"
tell active sheet
set lastIndex to first row index of last cell of (get used range)
repeat with i from 2 to lastIndex
set query to value of range ("A" & i)
set pp to my find_filenames(query, srcdir, type, mindepth, maxdepth)
if pp = {} then -- not found
tell current application to set ts to do shell script "date +'%F %T%z'"
set entry to "Did not found a name with query word(s): " & query
my log_to_file("%-26s%s\\n", {ts, entry}, logf)
else
set qq to {}
repeat with p in my pp
set p to p's contents
set q to my cp(srcdir & p, dstdir, {replacing:false})
if q ≠ "" then
set end of my qq to p -- found and copied
else
set end of my rr to srcdir & p -- found but not copied
end if
end repeat
set value of range ("B" & i) to my _join(return, qq) -- found and copied
--set value of range ("B" & i) to my _join(return, pp) -- found
end if
end repeat
end tell
end tell
-- log duplicates
if rr ≠ {} then
set ts to do shell script "date +'%F %T%z'"
set entry to "Did not copy the following node(s) due to existing name in destination: " & dstdir
my log_to_file("%-26s%s\\n", {ts, entry}, logf)
repeat with r in my rr
my log_to_file("%-28s%s\\n", {"", r's contents}, logf)
end repeat
end if
end script
tell o to run
end main
on log_to_file(fmt, lst, f)
string fmt : printf format string
list lst : list of strings
string f : POSIX path of log file
local args
set args to ""
repeat with a in {fmt} & lst
set args to args & space & a's quoted form
end repeat
do shell script "printf " & args & " >> " & f's quoted form
end log_to_file
on cp(src, dstdir, {replacing:_replacing})
string src : POSIX path of source file or directory
string dstdir : POSIX path of destination directory
boolean _replacing : true to replace existing destination, false otherwise
return string : POSIX path of copied file or directory, or "" if not copied
set rep to _replacing = true
if src ends with "/" then set src to src's text 1 thru -2
if dstdir ends with "/" then set dstdir to dstdir's text 1 thru -2
set sh to "
rep=$1
src=\"$2\"
dstdir=\"$3\"
dst=\"${dstdir}/${src##*/}\"
[[ $rep == false && -e \"$dst\" ]] && exit
cp -f -pPR \"$src\" \"$dstdir\" && echo \"$dst\" || exit $?
do shell script "/bin/bash -c " & sh's quoted form & " - " & rep & " " & src's quoted form & " " & dstdir's quoted form
end cp
on find_filenames(query, dir, type, mind, maxd)
string query : space delimited words to search
string dir : POSIX path of target root directory
string type : node type to retrieve
f => file
d => directory
integer mind : min depth of nodes in dir to retrieve
integer maxd : max depth of nodes in dir to retrieve
return list : list of POSIX path of found node(s)
script o
property exclude_list : {"Mini", "and", ""} -- list of words to be excluded from query
property pp : _split(space, NFD(query))
property qq : {}
property rr : {}
-- exclude words in exclude_list from query words
repeat with p in my pp
set p to p's contents
if p is not in my exclude_list then set end of my qq to p
end repeat
-- build arguments for find(1)
(* query words are compared with tokens delimited by _ or . in file name *)
repeat with q in my qq
e.g. Given qq = {"apple", "orange", "bananna"}, rr is list of -
-iregex '.*[/_.]apple([_.].*|$)'
-iregex '.*[/_.]orange([_.].*|$)'
-iregex '.*[/_.]bananna([_.].*|$)'
( Note: |'s must be balanced even in comment... )
set q to quotemeta(q) -- quote non-alphanumeric characters to be recognised as literal in regexp
set end of rr to "-iregex '.*[/_.]" & q & "([_.].*|$)'"
end repeat
set |-iregex| to " \\( " & _join(" -and ", my rr) & " \\)"
set |-type| to " -type " & type
set |-mindepth| to " -mindepth " & mind
set |-maxdepth| to " -maxdepth " & maxd
-- build shell script
set sh to "export LC_ALL=en_GB.UTF-8
cd " & dir's quoted form & " || exit
/usr/bin/find -E . " & |-type| & |-mindepth| & |-maxdepth| & |-iregex| & " \\! -name '.*' -print0 |
/usr/bin/perl -CS -ln0e 'print substr($_, 2);'
-- run shell script
return paragraphs of (do shell script sh)
end script
tell o to run
end find_filenames
on NFD(t)
string t : source string
return Unicode text : t in NFD (Normalization Form D)
set pl to "/usr/bin/perl -CSDA -MUnicode::Normalize <<-'EOF' - \"$*\"
print $ARGV[0] ? NFD($ARGV[0]) : qq();
EOF"
do shell script "/bin/bash -c " & pl's quoted form & " - " & t's quoted form
end NFD
on quotemeta(t)
string t : source string
return string : t where all non-alphanumeric characters are quoted by backslash
set pl to "/usr/bin/perl -CSDA -e 'print quotemeta $ARGV[0];' \"$*\""
do shell script "/bin/bash -c " & pl's quoted form & " - " & t's quoted form
end quotemeta
on _join(d, tt)
string d : separator
list tt : source list
return string : tt joined with d
local astid, astid0, t
set astid to a reference to AppleScript's text item delimiters
try
set {astid0, astid's contents} to {astid's contents, {} & d}
set t to "" & tt
set astid's contents to astid0
on error errs number errn
set astid's contents to astid0
error errs number errn
end try
return t
end _join
on _split(d, t)
string or list d : separator(s)
string t : source string
return list : t splitted by d
local astid, astid0, tt
set astid to a reference to AppleScript's text item delimiters
try
set {astid0, astid's contents} to {astid's contents, {} & d}
set tt to t's text items
set astid's contents to astid0
on error errs number errn
set astid's contents to astid0
error errs number errn
end try
return tt
end _split
Hope this may help
H
Message was edited by: Hiroto (fixed some typos) -
Basic FMJ script now working...
Hi, I'm using a basic FMJ script that is not working at all...
package p2.voice;
import java.applet.*;*
*import java.awt.*;
import java.net.*;*
*import javax.media.*;
public class PlayerApplet extends Applet implements ControllerListener {
Player player = null;
public void init() {
setLayout(new BorderLayout());
try {
URL mediaURL = new URL("file://D:
Mes documents\\USherbrooke\\S6\\SVN\\src\\p2\\voice
sound.wav");
player = Manager.createPlayer(mediaURL);
player.addControllerListener(this);
catch (Exception e) {
System.err.println("Got exception "+e);
public void start() {
player.start();
public void stop() {
player.stop();
player.deallocate();
public void destroy() {
player.close();
public synchronized void controllerUpdate(ControllerEvent event) {
if (event instanceof RealizeCompleteEvent) {
Component comp;
if ((comp = player.getVisualComponent()) != null)
add ("Center", comp);
if ((comp = player.getControlPanelComponent()) != null)
add ("South", comp);
validate();
}I always get:
+2008-05-06 15:06:10 net.sf.fmj.ds.media.content.unknown.Handler setSource+
INFO: Path: D:\Mes documents\USherbrooke\S6\SVN\src\p2\voice\sound.wav
+2008-05-06 15:06:10 net.sf.fmj.ds.media.content.unknown.Handler setSource+
ATTENTION: java.lang.UnsatisfiedLinkError: no jdshow in java.library.path
java.lang.UnsatisfiedLinkError: no jdshow in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at net.sf.fmj.ds.media.content.unknown.Handler.setSource(Handler.java:82)
at javax.media.Manager.createPlayer(Manager.java:178)
at javax.media.Manager.createPlayer(Manager.java:247)
at javax.media.Manager.createPlayer(Manager.java:103)
at javax.media.Manager.createPlayer(Manager.java:83)
at p2.voice.PlayerApplet.init(PlayerApplet.java:14)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Got exception java.net.UnknownHostException: D
java.lang.NullPointerException
at p2.voice.PlayerApplet.start(PlayerApplet.java:22)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Do you have any idea ? The path to the file is ok, if I put a random path, it gaves me an error about not finding the path so...I also have a similar problem.
Whenever I try to run the basic JMF code seek.java:
import java.awt.*;
import java.awt.event.*;
import javax.media.*;
import javax.media.control.FramePositioningControl;
import javax.media.protocol.*;
import javax.media.protocol.DataSource;
* Sample program to demonstrate FramePositioningControl.
public class Seek extends Frame implements ControllerListener, ActionListener {
Player p;
FramePositioningControl fpc;
Object waitSync = new Object();
boolean stateTransitionOK = true;
int totalFrames = FramePositioningControl.FRAME_UNKNOWN;
Panel cntlPanel;
Button fwdButton;
Button bwdButton;
Button rndButton;
* Given a DataSource, create a player and use that player
* as a player to playback the media.
public boolean open(DataSource ds) {
System.err.println("create player for: " + ds.getContentType());
try {
p = Manager.createPlayer(ds);
} catch (Exception e) {
System.err.println("Failed to create a player from the given DataSource: " + e);
return false;
p.addControllerListener(this);
p.realize();
if (!waitForState(p.Realized)) {
System.err.println("Failed to realize the player.");
return false;
// Try to retrieve a FramePositioningControl from the player.
fpc = (FramePositioningControl)p.getControl("javax.media.control.FramePositioningControl");
if (fpc == null) {
System.err.println("The player does not support FramePositioningControl.");
System.err.println("There's no reason to go on for the purpose of this demo.");
return false;
Time duration = p.getDuration();
if (duration != Duration.DURATION_UNKNOWN) {
System.err.println("Movie duration: " + duration.getSeconds());
totalFrames = fpc.mapTimeToFrame(duration);
if (totalFrames != FramePositioningControl.FRAME_UNKNOWN)
System.err.println("Total # of video frames in the movies: " + totalFrames);
else
System.err.println("The FramePositiongControl does not support mapTimeToFrame.");
} else {
System.err.println("Movie duration: unknown");
// Prefetch the player.
p.prefetch();
if (!waitForState(p.Prefetched)) {
System.err.println("Failed to prefetch the player.");
return false;
// Display the visual & control component if there's one.
setLayout(new BorderLayout());
cntlPanel = new Panel();
fwdButton = new Button("Forward");
bwdButton = new Button("Backward");
rndButton = new Button("Random");
fwdButton.addActionListener(this);
bwdButton.addActionListener(this);
rndButton.addActionListener(this);
cntlPanel.add(fwdButton);
cntlPanel.add(bwdButton);
cntlPanel.add(rndButton);
Component vc;
if ((vc = p.getVisualComponent()) != null) {
add("Center", vc);
add("South", cntlPanel);
setVisible(true);
return true;
public void addNotify() {
super.addNotify();
pack();
* Block until the player has transitioned to the given state.
* Return false if the transition failed.
boolean waitForState(int state) {
synchronized (waitSync) {
try {
while (p.getState() < state && stateTransitionOK)
waitSync.wait();
} catch (Exception e) {}
return stateTransitionOK;
public void actionPerformed(ActionEvent ae) {
String command = ae.getActionCommand();
if (command.equals("Forward")) {
int dest = fpc.skip(1);
System.err.println("Step forward " + dest + " frame.");
} else if (command.equals("Backward")) {
int dest = fpc.skip(-1);
System.err.println("Step backward " + dest + " frame.");
} else if (command.equals("Random")) {
if (totalFrames == FramePositioningControl.FRAME_UNKNOWN)
System.err.println("Cannot jump to a random frame.");
else {
int randomFrame = (int)(totalFrames * Math.random());
randomFrame = fpc.seek(randomFrame);
System.err.println("Jump to a random frame: " + randomFrame);
int currentFrame = fpc.mapTimeToFrame(p.getMediaTime());
if (currentFrame != FramePositioningControl.FRAME_UNKNOWN)
System.err.println("Current frame: " + currentFrame);
* Controller Listener.
public void controllerUpdate(ControllerEvent evt) {
if (evt instanceof ConfigureCompleteEvent ||
evt instanceof RealizeCompleteEvent ||
evt instanceof PrefetchCompleteEvent) {
synchronized (waitSync) {
stateTransitionOK = true;
waitSync.notifyAll();
} else if (evt instanceof ResourceUnavailableEvent) {
synchronized (waitSync) {
stateTransitionOK = false;
waitSync.notifyAll();
} else if (evt instanceof EndOfMediaEvent) {
p.setMediaTime(new Time(0));
//p.start();
//p.close();
//System.exit(0);
} else if (evt instanceof SizeChangeEvent) {
* Main program
public static void main(String [] args) {
if (args.length == 0) {
prUsage();
System.exit(0);
String url = "file:///C://Workspace_Surjeet//SampleSet//topgun3d.mpg";
MediaLocator ml;
if ((ml = new MediaLocator(url)) == null) {
System.err.println("Cannot build media locator from: " + args[0]);
prUsage();
System.exit(0);
DataSource ds = null;
// Create a DataSource given the media locator.
try {
ds = Manager.createDataSource(ml);
} catch (Exception e) {
System.err.println("Cannot create DataSource from: " + ml);
System.exit(0);
Seek seek = new Seek();
if (!seek.open(ds))
System.exit(0);
static void prUsage() {
System.err.println("Usage: java Seek <url>");
}thats available at the sun's site, I am getting:
create player for: video.mpeg
Jun 5, 2008 11:45:27 AM net.sf.fmj.ds.media.content.unknown.Handler setSource
INFO: Path: C:\workspace_Surjeet\SampleSet\topgun3d.mpg
Jun 5, 2008 11:45:27 AM net.sf.fmj.ds.media.content.unknown.Handler setSource
WARNING: java.lang.UnsatisfiedLinkError: no jdshow in java.library.path
java.lang.UnsatisfiedLinkError: no jdshow in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at net.sf.fmj.ds.media.content.unknown.Handler.setSource(Handler.java:82)
at javax.media.Manager.createPlayer(Manager.java:178)
at javax.media.Manager.createPlayer(Manager.java:247)
at Seek.open(Seek.java:64)
at Seek.main(Seek.java:244)
Failed to create a player from the given DataSource: javax.media.NoPlayerException: No player found for file:///C://Workspace_Surjeet//SampleSet//topgun3d.mpg
Am using JMF code since FMJ claims to be API compatible with JMF.
Need immediate help. -
Gallery script help, please
Gallery script help, please
Hello,
I'm new to actionscript in general, I do know a little...
I foung a gallery script, modified many things, the images
open fine, everything is working, but here's the thing:
the gallery is in 3 sections, red, blue and yellow.
I would like to know how, what, and where to put a script so
that if a "the small red image #1" is clicked, I can load any sort
of a movie on top of the "the BIG red image #1" or #2 or 3 and so
on...same goes for the blue and yellow...
If I figured things correctly on my own...the small thumbnail
images of the gallery are not buttons, that's why I can't attach a
movie (let's say) to them...but it is all written in script, using
the horizontal and vertical position of the mouse to open the large
images of the gallery...
So, I don't know how to figure things out, to attach a
specific movie to a specific thumbnail...
p.s.: I think the script that controls the gallery is in
symbol 120
I really would appreciate the help
Merry Christmas in advance to everyone
Sandra
here are all the files...
http://www.gentro.ca/sandra_test.zipThere's a great tutorial on kirupa...
click
here for link -
firefox not responding, freezes, sometimes responds after a few minutes, other times a pop-up appears asking if I want to stop script - help please
Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
* Don't make any changes on the Safe mode start window.
See:
* [[Troubleshooting extensions and themes]]
* [[Troubleshooting plugins]]
If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
* Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
* Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit") -
Basic script help for a newbie?!?!
Need help with a basic script, I need to display 5 input fields in a single dynamic field. And i need them to have a certain order of display, ie: input 1 is displayed on line 1, 2 on the next line, etc. any help would be appreciated
I have been trying various scripts but i either make the second input field replace the first one, or i cant get the vars to populate the field with a button.. Im kinda lost.Show what you have tried so far that give you the results where you either replace fields or can't get vars to populate them with a button.
-
Basic Flash Page, Script Help Please!
So, I realize I'm an idiot, but I'm trying to teach myself flash because I need to make a basic flash page. I am going by this tutorial:
http://www.flash-game-design.com/flash-tutorials/basic-Website-flash-tutorial.html
I have modified it (going step by step mind you) and now that it's over, instead of the page loading normally, it just goes from page to page without clicking on a link at all. Just goes from home, to about, to artists, etc.
I get no errors so... I'm a little lost.
I've uploaded the swf for reference.I always say to doublecheck the instance names... you'd be surprised how often some says they're okay when they're not. Sometimes they are using library names, not instances names, and something they simply did not assign instance names.
Your description of how the buttons are related to a movieclip isn't clear, but if the traces I mentioned come out, then the buttons are working.
I wish there was a way I could see the full set of messages for this posting (like the old system)... at this point I have to guess what I remember seeing... Do you have frame labels in your section mc that match the calls in your buttons functions?
For the home page issue... If it disappears it is likely going to another frame. If a command says gotoAndPlay... and you're already there, it will advance in the timeline even if there is a stop in that frame (the stop is used up)
Here's a routine that worked for another posting as far as getting the file to upload in the forum...
1) zip the fla file
2) rename the zip file to have a txt extenstion -
Hi,
I have a number of procedures where the actual SQL is generated dynamically depending on the different parameters pass in.
I need to test that it creates valid SQL for the different permutations of parameters.
I think I am nearly there (See below). My issue is the error reporting....
I want it to simplyu run an anonymous block and only report something to me if an error occurs - I just want to see the error.
I will be running either via SQL+ or SQL Developer.
Any tips / corrections or enhancements would be much appreciated.
Here's what I cam up with................
DECLARE
P_REPORT_PROCESS_ID NUMBER;
P_TRACE_FLAG NUMBER;
P_PAY_LIABILITIES NUMBER;
P_STMNT_RUN_ID NUMBER;
V_PID NUMBER;
V_TEST VARCHAR2(10);
BEGIN
--INITIALISE VARS
P_REPORT_PROCESS_ID := NULL;
P_TRACE_FLAG := NULL;
P_PAY_LIABILITIES := NULL;
P_STMNT_RUN_ID := NULL;
--GET NEXT SEQ VALUE
SELECT REPORT_PROCESS_ID_SEQ.NEXTVAL INTO V_PID FROM DUAL;
--TEST 1
--TEST 2
--ETC
V_TEST := 'TEST '||3;
RPT_POP_COMMON_PMT_DETAIL(
P_REPORT_PROCESS_ID => V_PID, IS THIS CORRECT WAY TO DO THIS
P_TRACE_FLAG => 1,
P_PAY_LIABILITIES => -1,
P_STMNT_RUN_ID => -1);
--==========================================================
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001, V_TEST || SQLCODE ||SQLERRM);
END;You are on the right track. You might want to nest the PL/SQL blocks for exception handling but that's about all I have to suggest
Be aware that dynamic code is very complex. Exception handling and maintenance can quickly spiral out of control if you care not careful. If you must use this technique try not to create blocks with any more complexity than you absolutely have to.
The other problem with dynamic PL/SQL is debugging. You have to figure out what caused the run-time errors you are getting ... the generated code or the code doing the generating? Very tight exception handling is necessary to do dynamic PL/SQL effectively.
Good luck! -
I've got very little experience with scripting in the UCCX 9.1.2 and have a customer I've recently upgraded that would like to add a variable to an existing script.
They need to add the ability to steer the caller to an inclement weather message should the need arise. I know I could do this by creating an if then statement in the work hours section that basically says if the number of logged in agents during normal work hours equals 0 send it to a trigger that is tied to a mailbox that has a message saying no one is available. I could then use the alternate greeting to advise of inclement weather and let the end user manage that greeting.
My issue is that I dont know scripting well enough to input the correct syntax in the if then expression.
Is there anyone that could help me with this? The script is attached.
If there is an easier way that I'm unaware of to accomplish this, I'm open to any suggestions.
Thanks in advance for any help and for taking the time to look at this!!Hi there,
You should move this post over to the Contact Center sub forum
https://supportforums.cisco.com/community/netpro/collaboration-voice-video/contact-center?view=discussions&start=0
Lots of excellent people over there who can help
Cheers!
Rob
"Seek it out and ye shall find "
- OneRepublic -
Scripting help needed... please
Help,
I know this is a fairly basic scripting question, but for some stupid reason I just can't seem to get it.
I am creating a DVD that has 2 different menus.
There are only one set of tracks, but 2 different menus. What I want is something that tells the track to return to menu 1 if it played from menu 1 or to go to menu 2 if it played from menu 2
Help please.
ThanksHi
I think this is what you are looking for: * Multiple Menus with GPRM based button jumps * (Thanks Hal!)
Hope that helps !
Alberto -
Java Midlet script help.. asap
hi, i've been fiddling with java midlet/m3g game programming for a few months, anyways.. i'm just trying to see if it is possible for a noob like me
to program a mobile java game which is a 3rd perosn shooter. I have made a M3G file, using 3DsMax - exporting the file to a " M3G" with a camera and world in it.
so.. the MIDlet is what i'm totally helpless with, i donono the basics of writing one, but i know how the script sorta goes. anyways.. all i want is to know how to
write a MIDlet script so that the m3g character on the screen can move forwards.bws,lft,rgt...
and i think you have to create frames for a movment for something..?.. i donono teach me plz..
oh.. and also.. i use j2me wireless toolkit, thats what ur soppost to use .. right?
jim, thxxjimSTHD wrote:
hi, i've been fiddling with java midlet/m3g game programming for a few months, anyways.. i'm just trying to see if it is possible for a noob like me
to program a mobile java game which is a 3rd perosn shooter. I have made a M3G file, using 3DsMax - exporting the file to a " M3G" with a camera and world in it.
so.. the MIDlet is what i'm totally helpless with, i donono the basics of writing one, but i know how the script sorta goes. anyways.. all i want is to know how to
write a MIDlet script so that the m3g character on the screen can move forwards.bws,lft,rgt...
and i think you have to create frames for a movment for something..?.. i donono teach me plz..
oh.. and also.. i use j2me wireless toolkit, thats what ur soppost to use .. right?
jim, thxx1) putting urgent or asap in your subject makes it seem as though your problem is more important than anyone elses - this will get you less help
2) using sms talk makes it hard for people to understand you - this will get you less help
3) showing no effort - such as looking at sample code and stating where you don't understand - this will get you less help.
4) not having a specific question - such as asking someone to teach you everything about subject x - we are not your teacher - this will get you less help.
5) when posting code not using code tags - this will get you less help
Start by improving on the infractions you have committed from this list. -
Hi,
I am trying to put together a script with the following pseudo code but I am struggling to find the best way to do it. I have the basics in place. It is more a question of where to use if/else, switch etc...
variable1 gets list of folder names from directory
use read-host to get user input and store in variable2
check if variable2 matches any of the entries from variable1
if variable2 matches variable1, move on to the next question.
if not ask them to re-enter a new folder name
Can anyone help me out?What I would like to do is output $vms. I can see that it outputs something but it is just a blank space in PS. Please bear in mind that the code is being used by vSphere PowerCLI.
$vlanlist = Get-VirtualPortGroup
$vlanlist | Select-Object -Unique name | where {$_.name -like "*10G*"}
### folder
# Get all possible folder names in vCenter at the top level.
$folderlist = Get-Folder | Where-Object {$_.ParentId -eq "Folder-group-v3" -or $_.ParentId -eq "Folder-group-v179"}
$valid_folder = $false
do
# Enter folder name containing VMs
$folder = Read-Host "Enter the folder name which contains the VMs"
if ($folderlist -like $folder)
$valid_folder = $true
# Get all VMs in the user selected folder
$vms = Get-VM -Location "$folder"
Clear-Host
else
$valid_folder = $false
Clear-Host
Write-Host "Folder name doesn't exist. Please re-enter."
} Until ($valid_folder)
### VLAN & ISO
# Datastore
$ds = "ISO Share"
# Path and ISO
$iso = "Tools\VMware Tools Drivers.iso"
# Get list of all VLANs on all hosts in vCenter with 10G in name
$vlanlist = Get-VirtualPortGroup | Select-Object -Unique name | where {$_.name -like "*10G*"}
#vlan
$valid_vlan = $false
do
# Enter VLAN for 10GB NIC
$vlanlist
$vlan = Read-Host "Enter the VLAN name from the list above to use for 10GB networking."
if ($vlanlist -like $vlan)
$valid_vlan = $true
# Set VMXNET3 NIC, change VLAN
$vms | Get-NetworkAdapter | Set-NetworkAdapter -Type Vmxnet3 -NetworkName $vlan -Confirm:$false
# Mount VMware Tools ISO
$vms | Get-CDDrive | Set-CDDrive -StartConnected:$true -IsoPath "[$ds] $iso" -Confirm:$false
else
$valid_vlan = $false
Clear-Host
Write-Host "VLAN name doesn't exist. Please re-enter."
} Until ($valid_vlan) -
APPLE SCRIPT HELP! Simple Renaming Script
I dont have any experience with apple script but desperately needed this for a work issue. I basically have tons of files with all the same type of name and need to send the first two numbers in the file to the end of the file as a suffix... so this...
01 alexa_02.mp3
needs to turn into this
01 alexa_02_01.mp3
So the function is take the first two characters from the file name of all the files in the folder and rename them with a suffix. Here is what I have so far.
PLEASE HELP! Im desperate!
[CODE]try
tell application "Finder" to set the source_folder to (choose folder with prompt "Pick the folder containing the files to rename:") as alias
end try
display dialog "Change Suffix to First Two Characters of File Name:" buttons {"Send The Pids!", "Cancel"}
set the button_pressed to the button returned of the result
set the item_list to list folder source_folder without invisibles
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
set this_item to item i of the item_list
set this_item to (source_folder & this_item) as alias
set this_info to info for this_item
set the current_name to the name of this_info
tell application "Finder"
if the button_pressed is "Send The Pids!" then
set the filename to the (current_name & the characters 1 thru 2 of current_name) as string
set orig to quoted form of POSIX path of current_name
set dest to source_folder & filename
try
set y to dest as alias
on error
set dest to quoted form of POSIX path of dest
set command to "mv " & orig & " " & dest
do shell script command
end try
end if
end tell
end repeat[/CODE]Made a short script on my own... normally you could do this using the Finder and run a recursive algorythm, but if you just use find to find all files in a folder that ft your criteria and use these links to generate a list of aliases (posix files) it is way faster and acomplished with less code :-)
set myfolder to characters 1 through -2 of (POSIX path of ((choose folder) as alias)) as text
set foundfiles to every paragraph of (do shell script "find " & quoted form of myfolder & " -type f -iname \"*.mp3\"")
repeat with afile in foundfiles
set afile to ((afile as text) as POSIX file as alias)
tell application "Finder"
set filename to name of afile
set filesuffix to (characters -4 through -1 of filename) as text
set addonsuffix to characters 1 through 2 of filename
set filename to (characters 1 through -5 of filename) as text
set newfilename to filename & "_" & addonsuffix & filesuffix
set name of afile to newfilename
end tell
end repeat -
I hope this is the right forum - sorry if it's not. I'm working with Excel Macros. Having a few problems adjusting to Mac from PC. I want to do a send key type command to close a web window (command F4). In my PC, the command was:
Application.SendKeys "%({F4})"
I'd like to do a send key type command on the mac for "command+F4".
I have no idea what I'm doing - I admit, but I've basically successfully pieced together bits and pieces of help from various web sources and made some macros that do what I need. This is one I haven't been able to figure out.
Thank you so much and again, I'm a newbie, so be kind! Thanks :-)
Katbump *
Maybe you are looking for
-
Every instruction Mozilla offers to find or to do something contains a term or a phrase that is indeciphrable. I have been trying to change "Cookie Settings" so of course Mozilla advises me to click the Mozilla button at the top of the page. And of c
-
An Apple genius told me to delete all my SMS for stability sake, should I do it?
I'm experiencing random reboots on my iPhone4 so i've been to an Apple Genius Bar. He told me my problems might come from a corrupted backup file. To try to get rid of this I shall restore my iPhone and register it as a New One. In the process I will
-
Movies not copying to any iPod from iTunes
I am suddenly unable to copy movies to my iPods. I manually manage them due to the size of my library. I've tried copying movies to a 60G Video iPod, and to a 3rd Generation iPod Nano (this nano actually is brand new from the store today, replacing a
-
Banks Agree to Erase Debts From Credit Reports After Bankruptcies
FYI - "Under federal law, once a borrower has erased a debt in bankruptcy, banks are required to update the credit reports to indicate that the debt is no longer owed, and remove any notation of "past due" or "charged off."" http://www.nytimes.com/20
-
Opening an eps causes Illustrator CS3 to lock up
I am running Illustrator CS3 on a Mac G4 laptop running 10.4.11. Today I tried to open an EPS file, of the same time that I've opened before, I Illustrator looks up -- the spinning beach ball. I've tried to open the EPS file from within Illustrator,