
-----------------------------------
liam438
Tue Mar 19, 2019 9:35 am

need help with inputting a text field...
-----------------------------------
i get the error message "deferred subroutine has not been resolved" 
also its the file called gave ver 3.1 its the newest version im working on.

this is the part with the text field.

%buttons%//////////////////////////////////////////////////////////////////////////////////////
proc textrun (text : string)
    input := GUI.GetText (commandpromp)
    cmdrun := true
end textrun
process button1
    var draw : int := GUI.CreateButtonFull (558, 350, 50, "Inventory", Invwind, 50, "h", true)
    commandpromp := GUI.CreateTextFieldFull (3, 14, 465, "", textrun, GUI.INDENT, 0, 0)
    GUI.Refresh
    loop
        exit when GUI.ProcessEvent
    end loop
    GUI.Refresh
end button1

-----------------------------------
liam438
Fri Mar 22, 2019 12:38 pm

RE:need help with inputting a text field...
-----------------------------------
ok so i have been looking and it seems the problem revolves around the deferred subroutine has not being resolved. i really need help on this.

-----------------------------------
Insectoid
Tue Mar 26, 2019 3:15 pm

RE:need help with inputting a text field...
-----------------------------------
I didn't download the file, but do you have any forward declared functions or procedures that you didn't write bodies for?

-----------------------------------
liam438
Thu Mar 28, 2019 11:28 am

Re: RE:need help with inputting a text field...
-----------------------------------
I didn't download the file, but do you have any forward declared functions or procedures that you didn't write bodies for?

i only have 2 forward procedures. and they both have body's. one of them is used as a procedure for a button tho.

-----------------------------------
liam438
Thu Mar 28, 2019 11:39 am

Re: need help with inputting a text field...
-----------------------------------
This is part of a widget module that opens when the error happens.

% Window must already be set up
    procedure HandleKeystroke (window : int)
        var ch := getchar

        % Check if a menu shortcut
        var menubar : ^MenuBarClass := GetMenuBarForWindow (window)

        % Check menus
        if menubar not= nil then
            if menubar -> ConsiderKeystroke (ch) then
                % Was a menu shortcut.
                return
            end if
        end if

        % Check widgets
        var widget : ^GenericWidgetBodyClass := WidgetGlobals.firstWidget
        loop
            exit when widget = nil
            if widget -> GetWindow = window and
                    objectclass (widget) >= GenericActiveWidgetClass and
GenericActiveWidgetClass (widget).ConsiderKeystroke (ch)  Process "button1" : Deferred subroutine has not been resolved.
                    then
                % Was a widget shortcut.
                return
            end if
            widget := widget -> GetNext
        end loop

        % Check user keystroke handler
        if keyEventHandler not= DefaultKeyEventHandler then
            keyEventHandler (ch)
        end if
    end HandleKeystroke

-----------------------------------
Insectoid
Thu Mar 28, 2019 5:21 pm

RE:need help with inputting a text field...
-----------------------------------
Can you move the body closer to the top of the code, or remove the forward declaration entirely? I suspect that Turing doesn't see your body declaration for whatever reason. Could be a typo, could be something else.

-----------------------------------
liam438
Wed Apr 03, 2019 12:08 pm

Re: need help with inputting a text field...
-----------------------------------
this is the entire program to make it easy for you guys.

import GUI
var bal : int := 0
var shopon : boolean := false
type Items :
    record
        Name : string
        Desc : string
        Healing : int
        Damage : int
        Has : boolean
        Amount : int
        Block : int
    end record
const size : int := 25   % The buttons size.
const border : int := 3
const Buttonx : int := 20
const Buttony : int := 340
%////Var////%
var button1y, button2y, button3y, button4y, button5y, button6y, button7y, button8y, button9y, button10y : int := 0
var button1x, button2x, button3x, button4x, button5x, button6x, button7x, button8x, button9x, button10x : int := 0
var winID1, winID2, starButton, mapleButton, starPic, mapleLeafPic, picID, picID1, picID2, picID3, picID4, picID5, picID6, picID7, picID8, picID9, space, wsb, ssb, isb, dsb : int
var shb, mhb, lhb, wshb, ishb, dshb, statfont, commandpromp : int
var winopen, combat, turn, cmdrun : boolean := false
var enemyhp, enemy : int
var count : int := 1
var damage : int := 5
var boxID : int := GUI.CreateTextBox (0, 40, 470, 360)
var equiped : string := "fists"
var shieldequiped, enemyname : string := ""
var start, name, nametest, stop, input, input2 : string
var health : int := 70
var item1, item2, item3, item4, item5, place, villagesub, cavesub, forestsub, defence : int := 0
var move, move2, move3 : int := 3
var commands : array 1 .. 5 of string
commands (1) := "buy"
commands (2) := "sell"
commands (3) := "attack"
commands (4) := "equip"
commands (5) := "use"
%////////items////////%
var woodsword : Items
woodsword.Name := "Wooden Sword"
woodsword.Desc := "Does 10 Damage"
woodsword.Damage := 10
woodsword.Has := false
woodsword.Amount := 0
var stonesword : Items
stonesword.Name := "Stone Sword"
stonesword.Desc := "Does 40 Damage"
stonesword.Damage := 40
stonesword.Has := false
stonesword.Amount := 0
var ironsword : Items
ironsword.Name := "Iron Sword"
ironsword.Desc := "Does 70 Damage"
ironsword.Damage := 70
ironsword.Has := false
ironsword.Amount := 0
var diamondsword : Items
diamondsword.Name := "Diamond Sword"
diamondsword.Desc := "Does 100 Damage"
diamondsword.Damage := 100
diamondsword.Has := false
diamondsword.Amount := 0
var smallheal : Items
smallheal.Name := "Small Health Potion"
smallheal.Desc := "Heals 10 Damage"
smallheal.Healing := 10
smallheal.Has := false
smallheal.Amount := 0
var medheal : Items
medheal.Name := "Medium Health Potion"
medheal.Desc := "Heals 40 Damage"
medheal.Healing := 40
medheal.Has := false
medheal.Amount := 0
var largeheal : Items
largeheal.Name := "Large Health Potion"
largeheal.Desc := "Heals 70 Damage"
largeheal.Healing := 70
largeheal.Has := false
largeheal.Amount := 0
var woodshield : Items
woodshield.Name := "Wooden Shield"
woodshield.Desc := "Gives 20 Defence"
woodshield.Block := 20
woodshield.Has := false
woodshield.Amount := 0
var ironshield : Items
ironshield.Name := "Iron Shield"
ironshield.Desc := "Gives 35 Defence"
ironshield.Block := 35
ironshield.Has := false
ironshield.Amount := 0
var diamondshield : Items
diamondshield.Name := "Diamond Shield"
diamondshield.Desc := "Gives 50 Defence"
diamondshield.Block := 50
diamondshield.Has := false
diamondshield.Amount := 0
forward proc Invwind ()
forward proc WindClose ()
statfont := Font.New ("sans serif:18:bold")
%//////////Create the button pictures////////%

% The star.
Draw.Star (border, border, border + size, border + size, black)
Draw.Star (border + 1, border + 1, border + size - 1, border + size - 1, black)
Draw.FillStar (border + 2, border + 2, border + size - 2, border + size - 2, brightred)
starPic := Pic.New (0, 0, 2 * border + size, 2 * border + size)

% The mapleleaf.
Draw.FillBox (border, border, border + size, border + size, white)
Draw.MapleLeaf (border, border, border + size, border + size, black)
Draw.MapleLeaf (border + 1, border + 1, border + size - 1, border + size - 1, black)
Draw.FillMapleLeaf (border + 2, border + 2, border + size - 2, border + size - 2, brightred)
mapleLeafPic := Pic.New (0, 0, 2 * border + size, 2 * border + size)
Draw.Cls
%////////Creat window//////%
picID := Pic.FileNew ("woodensword_icon32.jpg")
picID1 := Pic.FileNew ("stonesword_icon32.jpg")
picID2 := Pic.FileNew ("ironsword_icon32.jpg")
picID3 := Pic.FileNew ("diamondsword_icon32.jpg")
picID4 := Pic.FileNew ("potion_red.jpg")
picID5 := Pic.FileNew ("potion_yellow.jpg")
picID6 := Pic.FileNew ("potion_xp.jpg")
picID7 := Pic.FileNew ("woodshield.jpg")
picID8 := Pic.FileNew ("ironshield.jpg")
picID9 := Pic.FileNew ("diamondshield.jpg")
picID := Pic.Scale (picID, 2 * border + size, 2 * border + size)
picID1 := Pic.Scale (picID1, 2 * border + size, 2 * border + size)
picID2 := Pic.Scale (picID2, 2 * border + size, 2 * border + size)
picID3 := Pic.Scale (picID3, 2 * border + size, 2 * border + size)
picID4 := Pic.Scale (picID4, 2 * border + size, 2 * border + size)
picID5 := Pic.Scale (picID5, 2 * border + size, 2 * border + size)
picID6 := Pic.Scale (picID6, 2 * border + size, 2 * border + size)
picID7 := Pic.Scale (picID7, 2 * border + size, 2 * border + size)
picID8 := Pic.Scale (picID8, 2 * border + size, 2 * border + size)
picID9 := Pic.Scale (picID9, 2 * border + size, 2 * border + size)
Pic.SetTransparentColor (picID, white)
Pic.SetTransparentColor (picID1, white)
Pic.SetTransparentColor (picID2, white)
Pic.SetTransparentColor (picID3, white)
Pic.SetTransparentColor (picID4, white)
Pic.SetTransparentColor (picID5, white)
Pic.SetTransparentColor (picID6, white)
Pic.SetTransparentColor (picID7, white)
Pic.SetTransparentColor (picID8, white)
Pic.SetTransparentColor (picID9, white)
%/////////////////Proc/////////////%
%//////////////////////////////////%
%itemhas%
procedure itemif (var Amount : int, var Has : boolean)
    if Amount > 0 then
        Has := true
    elsif Amount = 0 then
        Has := false
    elsif Amount < 0 then
        Amount := 0
    end if
end itemif
%invname%
proc inventory (itemhas : boolean, itemname : string, itemnum : int)
    if count = 4 or count = 7 or count = 10 and itemhas = true then
        if itemhas = true then
            GUI.AddText (boxID, itemname)
            GUI.AddText (boxID, " (")
            GUI.AddText (boxID, intstr (itemnum))
            GUI.AddLine (boxID, ")")
        else
            GUI.AddLine (boxID, " ")
        end if
    else
        if itemhas = true then
            GUI.AddText (boxID, itemname)
            GUI.AddText (boxID, " (")
            GUI.AddText (boxID, intstr (itemnum))
            GUI.AddLine (boxID, ")")
        end if
    end if
    count := count + 1
end inventory
proc invrun
    inventory (woodsword.Has, woodsword.Name, woodsword.Amount)
    inventory (stonesword.Has, stonesword.Name, stonesword.Amount)
    inventory (ironsword.Has, ironsword.Name, ironsword.Amount)
    inventory (diamondsword.Has, diamondsword.Name, diamondsword.Amount)
    inventory (smallheal.Has, smallheal.Name, smallheal.Amount)
    inventory (medheal.Has, medheal.Name, medheal.Amount)
    inventory (largeheal.Has, largeheal.Name, largeheal.Amount)
    inventory (woodshield.Has, woodshield.Name, woodshield.Amount)
    inventory (ironshield.Has, ironshield.Name, ironshield.Amount)
    inventory (diamondshield.Has, diamondshield.Name, diamondshield.Amount)
end invrun
%enemy%/////////////////////////////////////////////////////////////////////////////////////////////////////
proc fariy
    enemyhp := 60
    GUI.AddLine (boxID, "a fariy blocks your path")
    combat := true
    enemyname := "fariy"
    loop
        turn := false
        loop
            exit when turn = true
        end loop
        exit when enemyhp = 1 then
        for hp : 1 .. Healing
            exit when health = 100
            health := health + 1
        end for
        Amount := Amount - 1
        GUI.AddText (boxID, "you are now at ")
        GUI.AddText (boxID, intstr (health))
        GUI.AddLine (boxID, "% health")
    else
        GUI.AddLine (boxID, "you dont have that item")
    end if
    WindClose
    Invwind
end healing
proc largehealing
    healing (largeheal.Amount, largeheal.Healing)
end largehealing
proc medhealing
    healing (medheal.Amount, medheal.Healing)
end medhealing
proc smallhealing
    healing (smallheal.Amount, smallheal.Healing)
end smallhealing
%shop%
proc shop
    GUI.AddLine (boxID, "you enter the shop")
    GUI.AddLine (boxID, "Shop Keep: welcome weary traveller to my shop")
    randint (item1, 500, 1000)
    randint (item2, 450, 750)
    randint (item3, 100, 250)
    randint (item4, 200, 250)
    randint (item5, 250, 300)
    GUI.AddLine (boxID, "======== SHOP ========")
    GUI.AddText (boxID, diamondsword.Name)
    GUI.AddText (boxID, " ")
    GUI.AddLine (boxID, intstr (item1))
    GUI.AddText (boxID, diamondshield.Name)
    GUI.AddText (boxID, " ")
    GUI.AddLine (boxID, intstr (item2))
    GUI.AddText (boxID, largeheal.Name)
    GUI.AddText (boxID, " ")
    GUI.AddLine (boxID, intstr (item3))
    GUI.AddText (boxID, ironshield.Name)
    GUI.AddText (boxID, " ")
    GUI.AddLine (boxID, intstr (item4))
    GUI.AddText (boxID, ironsword.Name)
    GUI.AddText (boxID, " ")
    GUI.AddLine (boxID, intstr (item5))
    GUI.AddLine (boxID, "======================")
end shop
body proc WindClose
    GUI.CloseWindow (winID1)
    winopen := false
end WindClose
body proc Invwind
    winID1 := Window.Open ("nobuttonbar;position:top;right")
    Window.Select (winID1)
    space := Buttonx
    if woodsword.Has = true then
        button1x := space
        button1y := Buttony
        if equiped = woodsword.Name then
            drawfillbox (button1x - 4, Buttony - 4, button1x + 40, Buttony + 40, green)
        end if
        wsb := GUI.CreatePictureButton (button1x, Buttony, picID, equipwood)
        Draw.Text (intstr (woodsword.Amount), button1x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if stonesword.Has = true then
        button2x := space
        button2y := Buttony
        if equiped = stonesword.Name then
            drawfillbox (button2x - 4, Buttony - 4, button2x + 40, Buttony + 40, green)
        end if
        ssb := GUI.CreatePictureButton (button2x, Buttony, picID1, equipstone)
        Draw.Text (intstr (stonesword.Amount), button2x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if ironsword.Has = true then
        button3x := space
        button3y := Buttony
        if equiped = ironsword.Name then
            drawfillbox (button3x - 4, Buttony - 4, button3x + 40, Buttony + 40, green)
        end if
        isb := GUI.CreatePictureButton (button3x, Buttony, picID2, equipiron)
        Draw.Text (intstr (ironsword.Amount), button3x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if diamondsword.Has = true then
        button4x := space
        button4y := Buttony
        if equiped = diamondsword.Name then
            drawfillbox (button4x - 4, Buttony - 4, button4x + 40, Buttony + 40, green)
        end if
        dsb := GUI.CreatePictureButton (button4x, Buttony, picID3, equipdiamond)
        Draw.Text (intstr (diamondsword.Amount), button4x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if smallheal.Has = true then
        button5x := space
        button5y := Buttony
        shb := GUI.CreatePictureButton (button5x, Buttony, picID4, smallhealing)
        Draw.Text (intstr (smallheal.Amount), button5x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if medheal.Has = true then
        button6x := space
        button6y := Buttony
        mhb := GUI.CreatePictureButton (button6x, Buttony, picID5, medhealing)
        Draw.Text (intstr (medheal.Amount), button6x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if largeheal.Has = true then
        button7x := space
        button7y := Buttony
        lhb := GUI.CreatePictureButton (button7x, Buttony, picID6, largehealing)
        Draw.Text (intstr (largeheal.Amount), button7x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if woodshield.Has = true then
        button8x := space
        button8y := Buttony
        if shieldequiped = woodshield.Name then
            drawfillbox (button8x - 4, Buttony - 4, button8x + 40, Buttony + 40, blue)
        end if
        wshb := GUI.CreatePictureButton (button8x, Buttony, picID7, equipwoodsh)
        Draw.Text (intstr (woodshield.Amount), button8x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if ironshield.Has = true then
        button9x := space
        button9y := Buttony
        if shieldequiped = ironshield.Name then
            drawfillbox (button9x - 4, Buttony - 4, button9x + 40, Buttony + 40, blue)
        end if
        ishb := GUI.CreatePictureButton (button9x, Buttony, picID8, equipironsh)
        Draw.Text (intstr (ironshield.Amount), button9x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    if diamondshield.Has = true then
        button10x := space
        button10y := Buttony
        if shieldequiped = diamondshield.Name then
            drawfillbox (button10x - 4, Buttony - 4, button10x + 40, Buttony + 40, blue)
        end if
        dshb := GUI.CreatePictureButton (button10x, Buttony, picID9, equipdiamondsh)
        Draw.Text (intstr (diamondshield.Amount), button10x - 10, Buttony - 10, defFontID, black)
        space := space + 50
    end if
    Font.Draw ("Player Damage:", 10, 15, statfont, brightred)
    Font.Draw (intstr (damage), 190, 15, statfont, black)
    Font.Draw ("Player Defence:", 10, 38, statfont, brightblue)
    Font.Draw (intstr (defence), 190, 38, statfont, black)
    if winopen = true then
        GUI.CloseWindow (winID1)
    end if
    var quitBtn : int := GUI.CreateButton (230, 10, 0, "Quit", WindClose)
    winopen := true
end Invwind
%/////////Process/////////%
%/////////////////////////%
process item
    loop
        itemif (woodsword.Amount, woodsword.Has)
        itemif (stonesword.Amount, stonesword.Has)
        itemif (ironsword.Amount, ironsword.Has)
        itemif (diamondsword.Amount, diamondsword.Has)
        itemif (smallheal.Amount, smallheal.Has)
        itemif (medheal.Amount, medheal.Has)
        itemif (largeheal.Amount, largeheal.Has)
        itemif (woodshield.Amount, woodshield.Has)
        itemif (ironshield.Amount, ironshield.Has)
        itemif (diamondshield.Amount, diamondshield.Has)
    end loop
end item
%death%
process death
    loop
        drawfillbox (480 + health * 2, 10, 680, 30, black)
        drawfillbox (480, 10, 479 + health * 2, 30, brightred)
        drawfillbox (480, 31, 680, 80, white)
        if health = 50 then
                move2 := 3
                move := 3
                bal := bal - 50
                health := 100
                GUI.AddLine (boxID, "your health has been restored")
                return
            elsif move2 = 2 then
                move2 := 3
                move := 3
                GUI.AddLine (boxID, "you leave the village and continue on your way")
                return
            elsif move2 = 1 and bal < 50 then
                GUI.AddLine (boxID, "you do not have enough coins for that")
                return
            end if
        else
            GUI.AddLine (boxID, "whaaaa")
        end if
    end if
end village
%forest%////////////////////////////////////////
proc woods
    GUI.AddLine (boxID, "you found a forest")
    GUI.AddLine (boxID, "enter?")
    GUI.AddLine (boxID, "yes/no")
    move := 1
    move2 := 3
    loop
        exit when move2 = 1 or move2 = 2
    end loop
end woods
%///Scripted places///%
loop
    exit when move3 = 1 or move3 = 2
end loop
move := 3
if move3 = 1 then
    move := 3
    move3 := 3
    village
elsif move3 = 2 then
    move := 3
    move3 := 3
    cave
else
    GUI.AddLine (boxID, "whoooot?")
end if
%//place randomizer//%
proc placerand
    loop
        Window.Update (-1)
        randint (place, 1, 3)
        GUI.AddLine (boxID, "")
        if place = 1 then
            cave
        elsif place = 2 then
            village
        elsif place = 3 then
            woods
        else
            GUI.AddLine (boxID, "what?")
        end if
    end loop
end placerand
placerand


-----------------------------------
Insectoid
Wed Apr 03, 2019 4:52 pm

RE:need help with inputting a text field...
-----------------------------------
It's tough to say exactly what's going on. It's possible that Gui buttons do not support deferred action procedures. It could be a bug in Turing. Gui buttons don't follow the same rules as the rest of Turing (well they do, but they don't). They do weird black magic, and you're usually better off, in my opinion, creating your own buttons with draw commands and Mouse.Where(). 

It's also unusual to need to forward declared procedures. Usually, you can restructure the program to not require it, and you're better off that way.

Finally, your liberal application of processes is going to bite you in the ass. Processes do funny things, the most annoying being they tend to cause random crashes and bugs that can't be reproduced and can't be diagnosed or fixed. Trust me, processes are bad news 99% of the time.

I don't use any of these features in my own code, as a rule. They're too unpredictable, and unnecessary.
