My program used to work :(

Discussion in 'Mac Programming' started by trey5498, Jul 23, 2010.

  1. trey5498 macrumors regular

    Joined:
    Jun 16, 2008
    #1
    I have a program that works on 10.5 but not on 10.6. How do I get it to work on 10.6 as well as 10.5 and 10.4?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    What doesn't work? Provide as much detail as possible. We have absolutely no way of knowing from the tiny, generic question you have asked.
     
  3. trey5498 thread starter macrumors regular

    Joined:
    Jun 16, 2008
    #3
    I apologize, however I thought there was just a switch in Xcode or a way to compile it to make it compatible.

    Here is a more detailed version. This program used to work on 10.4 and 10.5 and I made some changes (reduced the printers from 13 to a consolidated 4) and it stopped. I have somewhat narrowed it down to a certain file. The problem is that it works just fine on the developer machine but fails at the same place on every other machine, in OS X 10.5 and 10.6.

    Below is the code that stalls, it is shortened for brevity. It install a printer then sets it so it can work (in this case ONLY, one printer).

    Code:
    #import "PrnInstall.h"
    #import "DvrChk.h"
    
    
    @implementation PrnInstall
    //sets dvr as a pointer to DvrChk.m
    DvrChk * dvr;
    
    -(id) init
    {
    	
    	if ([super init]) {
    		// initializes the dvr as way to call the method from another file
    		dvr = [[DvrChk alloc] init];
    	}
    	return self;
    }
    -(void) dealloc
    {
    	[super dealloc];
    }
    
    - (NSString *)ATLABBWQ {
    	//will call the apropiate driver function with dvr and if the driver comes back as not there, it will be skiped, but if there the printer will be installed
    	BWQ1Dvr = [[dvr BWQ1:BWQ1Dvr] retain];
    	if([BWQ1Dvr isEqualToString:@"yes"]) {
    		//calls the system command of lpadmin to setup up the printer
    		system("lpadmin -p AT-LAB-BWQ -v lpd://at-lepus.ad.ufl.edu/AT-LAB-BWQ -P /Library/Printers/PPDs/Contents/Resources/HP\\ LaserJet\\ P4515.gz");
    		//calls the system command of cupsenabled to enable the printer to be used
    		system("cupsenable AT-LAB-BWQ");
    		//calls the system command of accept to allow the printer to accept jobs
    		system("accept AT-LAB-BWQ");
    		PRNinstalled = @"AT-LAB-BWQ";
    		return PRNinstalled;
    	} else {
    		return nil;
    	}
    }
    @end
    

    Below is the code for the call:
    Code:
    - (IBAction)ProcessButton:(id)sender 
    {
    	// calls the install file according to the correct OS version, hides the overview screen and shows a progress bar to show the progress
    	[prnOverview orderOut:nil];
    	[prnProcessing makeKeyAndOrderFront:self];
    	[prnProgress setIndeterminate:NO];
    	for(i=0; i<[arrPRNint count]; i++) {
    		//sets the length of the progress in time according to the count of arrPRNint array and updates the display until finished
    		[prnProgress setDoubleValue:100*i/(double)[arrPRNint count]];
    		[prnProgress displayIfNeeded];
    		stTmp = [arrPRNint objectAtIndex: i];
    
    		if([stDvrChk isEqualToString:@"Tiger"]) {
    			[arrInstalled addObject:objc_msgSend(prninstall104, NSSelectorFromString(stTmp))];
    		}
    		else {
    			[arrInstalled addObject:objc_msgSend(prninstall, NSSelectorFromString(stTmp))];
    		}
    	}
    
    	//hides the progress bar and brings up the wrapup screen.  Will display the printers that were installed correctly  and then display a message panel if there was an error in copying a driver.
    	[prnProcessing orderOut:nil];
    	[prnWrapup makeKeyAndOrderFront:self];
    	NSBeep();
    	for(i=0; i<[arrInstalled count]; i++) {
    		[endtextView insertText:[((NSString *) [arrInstalled objectAtIndex: i]) stringByAppendingString:@"\n"]];
    	}
    	//checks for errors in the installs and will display the error code to contact the help desk
    	tmp1 = [arrInstalled count];
    	stTmp = [NSString stringWithFormat:@" \n \n%d out of %d Printers have been Installed correctly\n", tmp, tmp1];
    	[endtextView insertText:stTmp];
    	[endtextView setEditable:false];
    	if (tmp != tmp1) {
    		NSRunAlertPanel(@"Driver Error", @"There was some error with insatalling the drivers.  Please contact the Help Desk for more information", @"Ok", nil, nil);
    	}		
    }
    
    and here is the Driver check that was called by BWQ1

    Code:
    - (NSString *)BWQ1: (NSString *)Bw1Dvr
    {
    	// will check for the driver and will return whether it is there or not, if no it will attempt to copy the file to the proper location
    	dvrchk = [fileManager fileExistsAtPath:sourcebw1];
    	if (dvrchk == NO)
    	{
    		[fileManager copyPath:@"/Volumes/PrinterInstaller/10.5/HP LaserJet P4515.gz" toPath:@"/Library/Printers/PPDs/Contents/Resources/HP LaserJet P4515.gz" handler:nil];
    	}
    	// checks to make sure the driver has been moved correctly and returns the value to the parent method
    
    	dvrchk = [fileManager fileExistsAtPath:sourcebw1];
    	if (dvrchk == NO)
    	{
    		Bw1Dvr = @"no";
    		return Bw1Dvr;
    	} else {
    		Bw1Dvr = @"yes";
    		return Bw1Dvr;
    	}
    
    }
    
     

Share This Page