new to this, flow of control no working the way I think it should - return

So I'm trying to make an automation script to help rip a very large CD library to mp3 with a program called CDex. The problem is that the script doesn't stay open.
The last time I tried to make a script it was really bad, but at least it worked. When it was running the AHK icon was in the systray, but this script appears to do nothing, and there's nothing in task manager under processes.
I'm fairly sure my problem lies with the flow of control and my use of "return". I thought that when you use that it starts the script back at the top?
Here's my code, please help me find where I've gone wrong.
ifwinexist, copying
{
return
}
else
{
Gosub chktry
return
}
chktry:
driveget, traystatus, statuscd
ifequal, traystatus, open
{
return
}
else
{
Gosub matchchk
return
}
matchchk:
ifwinexist, no match found
{
Gosub nomatch
return
}
else
{
Gosub inxmatch
return
}
nomatch:
sendinput {Tab}{Tab}{Tab}{Tab}{Enter}{f9}
Gosub renameunknownloop
return
inxmatch:
ifwinexist, inexact match found
{
sendinput {tab}{tab}{enter}
Gosub inicopy
return
}
else
{
Gosub inicopy
return
}
inicopy:
sendinput {f9}
ifwinexist, overwrite
{
sendinput {tab}{enter}
return
}
else
{
Gosub midoverproa
return
}
midoverproa:
ifwinexist, copying
{
Gosub midoverprob
return
}
else
{
return
}
midoverprob:
ifwinexist, overwrite
{
sendinput {tab}{enter}
return
}
else
{
Gosub midoverproa
return
}
renameunknownloop:
ifwinexist, copying
{
Gosub renameunknownloop
return
}
else
{
formattime, localtime,, MM/dd/yyyy-h.mm.tt
filemovedir, S:\Dad's music\no name, S:\Dad's music\%localtime%, r
return
}
return

You need to put your code into a loop so that it can keep checking the tray status, e.g. the following update checks every half second:
while 1
{
ifwinexist, copying
{
return
}
else
{
Gosub chktry
return
}
Sleep,500 // Sleep for 500 milliseconds
}
...

Related

How can I exclude two pages from optimization using Autoptimize snippet given below

I hope someone can help me here. How can I use this Autoptimize snippet to exclude two pages from optimization. The code below excludes the page "https//www.nameofsite/submit-an-article"
add_filter(‘autoptimize_filter_noptimize’,’submit_noptimize’,10,0);
function submit_noptimize() {
if (strpos($_SERVER[‘REQUEST_URI’],’submit-an-article’)!==false) {
return true;
} else {
return false;
}
}
I want to exclude also another page-->"https//:www.nameofsite.com/upload/file" I modified and tried to use the code below but it gave me an error.
add_filter(‘autoptimize_filter_noptimize’,’submit_noptimize’,10,0);
function submit_noptimize() {
if (strpos($_SERVER[‘REQUEST_URI’],’submit-an-article’, 'upload-
file')!==false) {
return true;
} else {
return false;
}
}
Perhaps, I did something wrong with code? Hope someone can help me here. I am just a newbie. Not really familiar in php. Thank you in advanced.
Try this:
// Disable autoptimize on all pages with the words "term1" or "term2" in the URL
add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0);
function my_ao_noptimize() {
if (strpos($_SERVER['REQUEST_URI'],'term1')!==false || strpos($_SERVER['REQUEST_URI'],'term2')!==false) {
return true;
} else {
return false;
}
}

Measure [in kbps] internet speed on mobile (ios)

I need to identify if the phone is connected to wifi which I can accomplish using
if (status == ReachableViaWiFi) {
return #"Wifi";
} else if (status == ReachableViaWWAN)
{
//connection type
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
return #"2G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
return #"2G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
return #"3G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
return #"3G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
return #"3G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
return #"2G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
return #"3G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
return #"3G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
return #"3G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
return #"3G";
} else if ([netinfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
return #"4G";
}
}
However, when the phone is using mobile data, I want to get the exact speed - something like 250kbps. I found some blogs where people suggested to download a file and record the time taken for downloading, thereby, calculating the speed. I don't want to use this approach.
Does Apple provide any library to get the speed?
If you know exact downloading speed then you needs to use approach said by blog people i.e download a file and record the time taken for downloading, thereby, calculating the speed. no any specific framework for this. using
transfer_speed = bytes_transferred / time_required_for_transfer
you can get downloading speed.
Using knowing network type (2G,3G,4G etc) you can give some specific speed to that network type. but main problem is you are not get exact speed.

Not all control paths return a value

if(newNode->getData()->name<currNode->getData()->name)
{
if(currNode->getLeftChild()==NULL)
{
return currNode;
}
compare(newNode,currNode->getLeftChild());
}
else if(newNode->getData()->name>=currNode->getData()->name)
{
if(currNode->getRightChild()==NULL)
{
return currNode;
}
compare(newNode,currNode->getRightChild());
}
else
{
currNode==NULL;
return currNode;
}
Does the last else not cover any other paths that could be taken?
Why am i still getting an error saying not all control paths return a value?
What am I missing? and any hints on a better solution would be nice!
Thank you for your time.
Use below code
if(newNode->getData()->name<currNode->getData()->name)
{
if(currNode->getLeftChild()==NULL)
{
return currNode;
}
compare(newNode,currNode->getLeftChild());
return currNode;
}
else if(newNode->getData()->name>=currNode->getData()->name)
{
if(currNode->getRightChild()==NULL)
{
return currNode;
}
compare(newNode,currNode->getRightChild());
return currNode;
}
else
{
currNode==NULL;
return currNode;
}
You are not returning any value in first and second else part
if u dont want to return anything just use return "";

else condition is not executing?

in this following else if ,the last else condtion is not executing ?
Please help me
if (Flag==1)
{
...
}
else if ([totalBooksId containsObject:currentbook])
{
...
}
else if (![totalBooksId containsObject:currentbook])
{
...
} else {
...
}
All variable have some values but still else is not executing.
the above else statement is not executing at all? Please help me
This is will work
if(Flag==1){
if([OwnList containsObject:currentbook]){
if(fileExists) {
[self renameReadButton];
}else if(!fileExists){
[self renameDownloadButton];
}
[self renameLendButton];
}
}
else if([totalBooksId containsObject:currentbook]){
//Checking bought books
if([OwnList containsObject:currentbook]){
if(fileExists){
[self renameReadButton];
}else {
[self renameDownloadButton];
}
} else{
[self renameBuyButton];
}
}
else if(![totalBooksId containsObject:currentbook]) {
if([freeList containsObject:currentbook]){
if(fileExists){
[self renameReadButton];
}else{
[self renameDownloadButton];
}
} else{
[self renameBuyButton];
}
}
If the last else on an else-if block is not hit it usually means either of these:
One of the conditions in the initial if clause or the following else-if clauses was true
One of the evaluated conditions altered the program path (exception, stack corruption, etc.)
The code of the entire if-else block was never reached
In your case it seems to be the first case, because one of the else if conditions is the inverse of another.
Either ([totalBooksId containsObject:currentbook]) is true, or !([totalBooksId containsObject:currentbook]) is true. To hit the final else, both of them must be false.
You have three statement
else if([totalBooksId containsObject:currentbook]) // first
{
}
else if(![totalBooksId containsObject:currentbook]) // second
{
}
else { [self renameBuyButton]; } // last
Last statement is not executed because first and second catch all possible situations.
First catch [totalBooksId containsObject:currentbook] == true , second cath [totalBooksId containsObject:currentbook] == false and there is no third possibility.

Blackberry File (Webworks)

I'm trying (Very simply) to get a file list of the camera directory using webworks.
The code I'm trying is as follows:
function displayPhotos(id) {
try {
var Dir, path, items;
if ((window.blackberry === undefined) || (blackberry.io === undefined) || (blackberry.io.file === undefined)) {
appendContent("photoDetails", "<p><i><b>blackberry.io.file</b> object not found (likely cause is WebWorks APIs are not supported by this user agent).</i></p>");
debug.log("displayPhotos", "blackberry.io.file object is undefined.", debug.error);
return false;
}
Dir = blackberry.io.dir;
path = "";
path = "file:///Device/home/user/camera"";
items = Dir.listFiles(path);
console.log(items);
//setContent(id, formatAsHTML(path, items));
}
catch(e) {
console.log("displayPhotos", e, debug.exception);
}
}
All I get back is error 1004 - I assume this is permissions based, but I fail to believe I can't get a READ on the camera fails - any one know anything?
Cheers!
Well I figured it out, hope this helps anyine getting the dreaded blackberry webworks error 1004.
You need to change device in the path to store. That's it really. This example works:
function displayPhotos(myFolder) {
try {
var Dir, path, items;
Dir = blackberry.io.dir;
path = "";
if (myFolder != undefined){
path = myFolder;
} else {
path = "file:///store/home/user/pictures";
//file:///store/home/user/camera
}
items = Dir.listFiles(path);
return items;
}
catch(e) {
console.log("displayPhotos", e, debug.exception);
}
}
function displayFiles(myFolder) {
try {
console.log("displayFiles", "in " + myFolder);
return displayPhotos(myFolder);
}
catch(e) {
console.log("displayFiles", e, debug.exception);
}
}
You can call it like so:
displayFiles();
Or specify a folder like so:
displayFiles("file:///store/home/user/camera");
Returns an array of filenames.
Hope this helps someone!

Resources