TweetFollow Us on Twitter

Mover Fix
Volume Number:4
Issue Number:12
Column Tag:ßasic School

QuickBasic's Statement Mover Fix

By Dave Kelly, Editorial Board

Statement Mover Fix

During the past month, I’ve been looking at the demo programs included with MS QuickBASIC 1.0. The programs exercise most of (but certainly not all) the syntax of QuickBASIC. Also utility programs are provided which can be used to help your development are:

‘AlertMover’ For copying Alert/Dialog resources

‘Cursor Editor’ For defining your own cursors

‘Demo Resources’ containing Alert resources

‘extra MBLC Remover’ removes unnecessary library resources from your application programs.

‘Pattern Editor’ For defining your own patterns

‘Print Listing File’ Print listings created at compile time.

‘renumber CODEs’ avoids code id conflicts

‘SortSub’ moves sub programs to the end of a Basic source code file

‘Statement Mover’ moves resources especially Library resources.

Missing from this list is a variable cross reference program and a program to compare the differences between two text files. Comparing differences between files is somewhat complex when programs don’t have line numbers to compare with.

The new version of ‘Statement Mover’ is much improved over the version included with MS BASIC 3.0 and the CLR Libraries. You can now copy most any kind of resource that has a resource name attached. But, don’t open up an open resource file or you get a bomb! That means you can’t open the System File or the ‘Statement Mover’ application. I haven’t worked on a fix for that one yet, but I have made a minor improvement to ‘Statement Mover’ which uses a dialog resource.

The routine I have written replaces the NewTypeDialog subprogram in ‘Statement Mover’. First the program’s volume reference number is retrieved and the dialog is displayed. Then a loop is set up to retrieve changes in the modal dialog. When a radio button is pressed the routine responds to it and updates the other buttons. The buttons represent a set of resource types which might be moved from one program or file to another. The edit field is updated with the resource type so that it will be passed when the routine is exited.

The dialog resource may be created with ResEdit or any other program that allows you to create dialogs. I used ProtoTyper™ to create the dialog so that I could try it out before I copied it into my QuickBASIC program. Because I had so many buttons in my dialog I used ResEdit to adjust the order of the buttons so that the ‘OK’ button would be the first one (ProtoTyper™ sets them up in the order that they were drawn and you can’t change the order without starting over).

Another thing that this dialog resource shows is a way to create the bold default buttons. Normally in Pascal or C you can draw the bold with the FrameRoundRect statement after defining the dialog item as a user item. A method that works is to define a PICT resource that looks like the bold roundrect and position it around the button which will be the default (usually the ‘OK’ button). I believe that you can do it this way from other languages too, although Inside Macintosh vol. 1 says to use the user items.

{1}
‘ NewTypeDialog Subprogram
‘ Replaces NewTypeDialog in Statement Mover Program
‘ Subprogram by Dave Kelly
‘ Portions derived from Prototyper.

‘Use these lines to test the program
‘ cancel%=0
‘ NewType$=””
‘ CALL NewTypeDialog(NewType$,cancel%)
‘ PRINT NewType$
‘ END

SUB NewTypeDialog(NewType$,cancel%) STATIC
    False=0:True=NOT False
    ExitDialog =False  ‘ Flag used TO EXIT the DIALOG

    Selection&=0  : ‘  DialogPtr;NAME of DIALOG
    index%=0 :’  FOR looping
    EditString$=”” :’ GET Text entered, temp holding
    itemHit%=0 : ‘ GET selection

    ‘ Start of DIALOG handler
    vref%=SYSTEM(7): ‘  Get program’s volume reference number.
    NewType$=””
    GetNewDialog vref%,10000,Selection&    ‘ Bring in the DIALOG resource

    ExitDialog=False  ‘   Do NOT EXIT DIALOG Handle loop yet
    itemHit%=0
    WHILE ExitDialog=False ‘  Start of DIALOG Handle loop
        ModalDialog Selection&, itemHit%   :’  WAIT until an item IS 
hit
        SELECT CASE itemHit%
            CASE 1        ‘ Handle the OK BUTTON being pressed
                ExitDialog=True ‘   {EXIT the DIALOG when This selection 
IS made}
                cancel%=False

            CASE 2   ‘     Handle the Cancel BUTTON being pressed
                ExitDialog=True  ‘  {EXIT the DIALOG when This selection 
IS made}
                SetDialogText Selection&,4,””
                cancel%=True

            CASE 5 TO 27
                FOR index%=5  TO 27 ‘ CLEAR ALL other radios
                    IF index%<>itemHit% THEN SetDialogBut Selection&,index%,1
                NEXT index%
                ‘ Setup the Dialog selections
                SetDialogBut Selection&,itemHit%,2
                IF itemHit%=5 THEN EditString$=”ALRT”
                IF itemHit%=6 THEN EditString$=”APPL”
                IF itemHit%=7 THEN EditString$=”BNDL”
                IF itemHit%=8 THEN EditString$=”CNTL”
                IF itemHit%=9 THEN EditString$=”CURS”
                IF itemHit%=10 THEN EditString$=”DITL”
                IF itemHit%=11 THEN EditString$=”DLOG”
                IF itemHit%=12 THEN EditString$=”DRVR”
                IF itemHit%=13 THEN EditString$=”FOND”
                IF itemHit%=14 THEN EditString$=”FONT”
                IF itemHit%=15 THEN EditString$=”FREF”
                IF itemHit%=16 THEN EditString$=”GNRL”
                IF itemHit%=17 THEN EditString$=”ICN#”
                IF itemHit%=18 THEN EditString$=”ICON”
                IF itemHit%=19 THEN EditString$=”MBAR”
                IF itemHit%=20 THEN EditString$=”MENU”
                IF itemHit%=21 THEN EditString$=”PAT”
                IF itemHit%=22 THEN EditString$=”PAT#”
                IF itemHit%=23 THEN EditString$=”PICT”
                IF itemHit%=24 THEN EditString$=”SIZE”
                IF itemHit%=25 THEN EditString$=”STR#”
                IF itemHit%=26 THEN EditString$=”STR “
                IF itemHit%=27 THEN EditString$=”WIND”
                SetDialogText Selection&,4,EditString$

            CASE ELSE
                FOR index%=5  TO 27 ‘ CLEAR ALL radio buttons
                    SetDialogBut Selection&,index%,1
                NEXT index%

        END SELECT
    WEND   ‘ Handle DIALOG items until EXIT selected
    GetDialogText Selection&,4,NewType$
    DisposeDialog Selection&  ‘       Flush the DIALOG out of memory
END SUB ‘     END of unit

The following Dialog resource file should either be created with Compiled with a resource compiler or recreated with ResEdit or Prototyper.

{2}
resource  ‘PICT’ (600, purgeable)
{
    49,
    {-1, -1, 35, 70},
    {17; 1; 160; 0; 130; 1; 0; 10; 255; 255; 255; 255; 0
    ; 35; 0; 70; 7; 0; 3; 0; 3; 11; 0; 21; 0
    ; 21; 64; 0; 1; 0; 1; 0; 35; 0; 70; 160; 0
    ; 131; 255}
};

resource  ‘DITL’ (10000 , “NewTypeDialog”)
{
  {
    {130, 146, 156, 207},
      Button {enabled, “OK”};
    {130, 26, 155, 88},
      Button {enabled, “Cancel”};
    {120, 246, 136, 297},
      StaticText {enabled, “Other:”};
    {120, 306, 136, 357},
      EditText {enabled, “”};
    {20, 26, 42, 90},
      RadioButton {enabled, “ALRT”};
    {40, 26, 60, 81},
      RadioButton {enabled, “APPL”};
    {60, 26, 82, 90},
      RadioButton {enabled, “BNDL”};
    {80, 26, 102, 90},
      RadioButton {enabled, “CNTL”};
    {100, 26, 120, 81},
      RadioButton {enabled, “CURS”};
    {20, 96, 42, 160},
      RadioButton {enabled, “DITL”};
    {40, 96, 62, 160},
      RadioButton {enabled, “DLOG”};
    {60, 96, 82, 160},
      RadioButton {enabled, “DRVR”};
    {80, 96, 102, 160},
      RadioButton {enabled, “FOND”};
    {100, 96, 122, 160},
      RadioButton {enabled, “FONT”};
    {20, 166, 40, 221},
      RadioButton {enabled, “FREF”};
    {40, 166, 62, 230},
      RadioButton {enabled, “GNRL”};
    {60, 166, 80, 221},
      RadioButton {enabled, “ICN#”};
    {80, 166, 100, 221},
      RadioButton {enabled, “ICON”};
    {100, 166, 120, 221},
      RadioButton {enabled, “MBAR”};
    {20, 236, 40, 296},
      RadioButton {enabled, “MENU”};
    {40, 236, 62, 300},
      RadioButton {enabled, “PAT “};
    {60, 236, 80, 291},
      RadioButton {enabled, “PAT#”};
    {80, 236, 102, 300},
      RadioButton {enabled, “PICT”};
    {100, 236, 120, 291},
      RadioButton {enabled, “SIZE”};
    {20, 306, 40, 361},
      RadioButton {enabled, “STR#”};
    {40, 306, 62, 370},
      RadioButton {enabled, “STR “};
    {60, 306, 80, 361},
      RadioButton {enabled, “WIND”};
    {123, 139, 161, 212},
      Picture {enabled, 600}
  }
};

resource  ‘DLOG’ (10000 , “NewTypeDialog”)
{
    {50, 120, 223, 504},
    1,
    invisible,
    noGoAway,
    0x1,
    10000,
    “NewTypeDialog”
};

I came across a bug in the AlertMover program which I include a fix here. The problem was that AlertMover would not save to an existing file. There are some fundamental problems with some of the sample programs on the QuickBASIC examples disk which are related to finding the filename of the application program. Microsoft added the SYSTEM(7) function after the manual was printed and so was probably not known or available at the time the demo programs were written. Changes could be made to the other programs in a similar manner. Here is the fix:

WAS:

‘    AlertMover
‘    © Sharon Zardetto Aker
‘    © 1988 by Microsoft Corp.
‘    Modified from Sharon Zardetto Aker’s original to take
‘    advantage of new QB features.
‘
‘------------------------------------------------------------
‘
    CLEAR,100000&
    OPTION BASE 1

SH=SYSTEM(6)    ‘Get screen height
SW=SYSTEM(5)    ‘Get screen width

IS:
‘    AlertMover
‘    © Sharon Zardetto Aker
‘    © 1988 by Microsoft Corp.
‘    Modified from Sharon Zardetto Aker’s original to take
‘    advantage of new QB features.
‘    Modified again so that it would create new files properly
‘    by Dave Kelly 9/17/88
‘------------------------------------------------------------
‘
    CLEAR,100000&
    OPTION BASE 1

DIM SHARED IOPB%(60),fil$   :’used by new subprogram ***************

SH=SYSTEM(6)    ‘Get screen height
SW=SYSTEM(5)    ‘Get screen width

WAS:
   IF SYSTEM(4) THEN    ‘If compiled...
        openResFile “Demo Resources”,ref%
    ELSE    ‘if interpreted, get File reference number of this source
        ref%=PEEKW(&HA5A)
    END IF
    ON BREAK GOSUB quit :BREAK ON
    MENU 1,0,1,”File”

IS:
   IF SYSTEM(4) THEN    ‘If compiled...
        PgmPath$=””
        ref%= SYSTEM(7)
        GetPathName ref%, PgmName$
        parse PgmName$,path$    ‘separate file name from the path
        OpenResFile PgmName$,ref%
    ELSE    ‘if interpreted, get File reference number of this source
        ref%=PEEKW(&HA5A)
    END IF
    ON BREAK GOSUB quit :BREAK ON
    MENU 1,0,1,”File”

Then add the following subprograms to the end: (These routines were taken from the ‘GetPathNames’ demo program which is included with MS QuickBASIC version 1.0). This is a great way to find the pathnames of files you are using.

‘----------------------------------------------------------------
‘   Gets the full path name of a file given the file reference
‘  number of file.  The file reference may be obtained from
‘    OpenResfile, SYSTEM(7), GetChanRefNum, or various low 
‘    memory locations.
‘
SUB GetPathName(ref%,path$) STATIC
    fil$=”” : Folder$=””
    GetFCBInfo IOPB%(0),fil$,ref%
    path$=fil$
    DirID&=IOPB%(29)*65536&+IOPB%(30)
    VRefNum%=IOPB%(26)
    WHILE DirID&<>1
        GetCatInfo IOPB%(0),Folder$,DirID&,VRefNum%
        path$=Folder$+”:”+path$
        DirID&=IOPB%(50)*65536&+IOPB%(51)
    WEND
END SUB

‘----------------------------------------------------------------
SUB parse(filename$,path$) STATIC
index%=1
    WHILE index% ‘<>0
        last%=index%
        index%=INSTR(index%+1,filename$,”:”)
    WEND
    IF last%=1 THEN  ‘there was no path
        path$=””
    ELSE             ‘divide filenamein$ into path$ and filename$
        path$=LEFT$(filename$,last%)
        filename$=RIGHT$(filename$,LEN(filename$)-last%)
    END IF
END SUB
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.