BUG: GetPicture "Invalid Function Call" after CHAIN (78387)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b

This article was previously published under Q78387

SYMPTOMS

Attempting to CHAIN to a program that uses the GetPicture toolbox routine (an MBLC stored in QuickBasic for Macintosh) will result in an "Invalid function call" (error 5) under the following conditions:

  • The program is run in the QuickBasic interpreter.
  • The program being chained from does not contain the PICT resource needed by GetPicture.
This problem occurs because the program being chained to attempts to use the resource fork of the original program (the program chained from) that was run. If the resource fork of the original program does not contain a PICT resource, then a call to the GetPicture toolbox routine will fail with an "Invalid function call" error.

This problem does not occur in a compiled program. In a compiled program, the resource fork of the program being chained from is closed and the resource fork of the program being chained to is used.

MORE INFORMATION

Steps to Reproduce Problem

  1. Launch QuickBasic
  2. From the code window of the QuickBasic development environment, enter the following code.
          CHAIN "ToolBoxSampler"
    						
  3. From the File menu, choose Save.
  4. In the "Save program as:" dialog box, type chainer and press ENTER.
  5. From the Run menu, choose Run Program.
  6. If the "Can't fine" ToolBoxSampler" dialog box appears, choose OK. Otherwise, go to step 9 below.
  7. Find ToolBoxSampler in the appropriate folder. ToolBoxSampler is a demonstration program supplied with Microsoft QuickBasic version 1.0. It is located in the QB Demos folder of the Examples disk.
  8. Highlight ToolBoxSampler and choose Open.
  9. From the dialog box introducing the ToolBoxSampler, choose OK. The error message "Invalid function call" will occur on the statement GetPicture ref%, 20, d!.

WORKAROUND

You can work around the problem by copying the PICT resource (needed by GetPicture) to the chained-from program, as follows:

  1. Launch ResEdit.
  2. From the files/folders list box, click on the folder containing ToolBoxSampler. Repeat this step as many times as necessary until the ToolBoxSampler is found.
  3. From the files/folders list box, select ToolBoxSampler. A list box containing the resources associated with ToolBoxSampler will appear.
  4. From the resource list box, click on PICT.
  5. From the Edit menu, choose Copy.
  6. Close the resource list box.
  7. From the file/folders list boxes remaining on the screen, close as many of the list boxes as necessary such that the program "chainer" created in step 4 above can be found.
  8. Click on chainer. A list box containing the resources associated with the program chainer will appear.
  9. From the Edit menu, choose Paste. PICT will be added to the list of resources.
  10. From the File menu, choose Quit.
  11. From the "Save 'chainer' before closing?" dialog box, select Yes.
  12. Follow steps 1 through 9 further above.
After being chained to, the ToolBoxSampler should run without error.

Modification Type:MajorLast Reviewed:10/23/2003
Keywords:kbbug KB78387