Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Error At Non-existent If Loop
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Alboxas




PostPosted: Sat Jan 23, 2016 10:38 pm   Post subject: Error At Non-existent If Loop

What is it you are trying to achieve?
Run a process


What is the problem you are having?
It displays a error saying that 'then' is expected. This error is shown at the top of the mapcreation.t file

Syntax error at 'open' expected 'then'


Describe what you have tried to solve this problem
going through the files, looking for open if loops, changing directories etc.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:



%1rst file/Main.t:
setscreen ("graphics:640,540")
%setscreen ("graphics: offscreenonly")
include "Classes/var.t"
%include "Classes/sounds.t"

%fork salt
%Pic.FileNewFrames ("salt.gif", pics, delayTime)
%Pic.DrawFrames (pics, 140, 90, picCopy, numFrames, 50, false)
%for i : 1 .. numFrames
%    Pic.Free (pics (i))
%end for
var frames : int := 0
for i : 0 .. 3 by 1
    down (i) := Pic.FileNew ("Sprites/Ephriam/Map Sprite/Down/" + intstr (i) + ".bmp")
    up (i) := Pic.FileNew ("Sprites/Ephriam/Map Sprite/Up/" + intstr (i) + ".bmp")
    left (i) := Pic.FileNew ("Sprites/Ephriam/Map Sprite/Left/" + intstr (i) + ".bmp")
    right (i) := Pic.FileNew ("Sprites/Ephriam/Map Sprite/Right/" + intstr (i) + ".bmp")
end for

process passive ()
    loop
        if characterpos = 1 then
            frames := frames + 1
            Sprite.ChangePic (character, up (frames))
            delay (100)
           
            if frames = 3 then
                frames := 0
            end if
        end if

        if characterpos = 2 then
            frames := frames + 1
            Sprite.ChangePic (character, down (frames))
            delay (100)
            if frames = 3 then
                frames := 0
            end if
        end if

        if characterpos = 3 then
            frames := frames + 1
            Sprite.ChangePic (character, left (frames))
            delay (100)
            if frames = 3 then
                frames := 0
            end if
        end if

        if characterpos = 4 then
            frames := frames + 1
            Sprite.ChangePic (character, right (frames))
            delay (100)
            if frames = 3 then
                frames := 0
            end if
        end if
       if mapend = 1 then
            exit
        end if
    end loop
end passive


fork passive ()
include "Character Movement.t"
include "Classes/return.t"
include "test.t"
fork boss1




%2nd file: return.t

process boss1
loop

    if bossnumber = 1 then
        include "ZebesianFight.t"
    end if

    if bossnumber = 2 then
        include "DragonFight.t"
    end if

    if bossnumber = 3 then
        include "KnightFight.t"
    end if

    if bossnumber = 4 then
        include "AxeManFight.t"
    end if
   
    end loop
end boss1




%3rd file: MapCreation.t
%Pic.ScreenLoad("MapBackground.bmp",0,0,picCopy);

open : stremin, "Maps/S"+intstr(mapnumber)+".txt", get %get dat data

for decreasing j : 19 .. 0 by 1
    for i : 0 .. 19 by 1
        exit when eof (stremin)
        get : stremin, nums
        %put stremin
        map (i, j) := nums
    end for
end for

for i : 0 .. 19 by 1
    for j : 0 .. 19 by 1
        if map (i, j) = 1 then
            Pic.ScreenLoad ("Sprites/Tileset/1.bmp", i * 20, j * 20, picCopy)
        end if
        if map (i, j) = 0 then
            drawfillbox (i * 20, j * 20, (i * 20) + 20, (j * 20) + 20, black)
        end if
        if map (i, j) = 2 then
            Pic.ScreenLoad ("Sprites/Tileset/3.bmp", i * 20, j * 20, picCopy)
        end if
        if map (i, j) = 5 then
            Pic.ScreenLoad ("Sprites/Tileset/2.bmp", i * 20, j * 20, picCopy)
        end if
        if map (i, j) = 6 then
            Pic.ScreenLoad ("Sprites/Tileset/4.bmp", i * 20, j * 20, picCopy)
        end if
        if map (i, j) = 3 then
            Pic.ScreenLoad ("Sprites/Tileset/1.bmp", i * 20, j * 20, picCopy)
            Pic.ScreenLoad ("Sprites/Tileset/leftclosed.bmp", i * 20, j * 20, picMerge)
        end if
        if map (i, j) = 7 then
            Pic.ScreenLoad ("Sprites/Tileset/7.bmp", i * 20, j * 20, picCopy);
        end if
         if map (i, j) = 8 then
            Pic.ScreenLoad ("Sprites/Tileset/8.bmp", i * 20, j * 20, picCopy);
        end if
        if map (i, j) = 9 then
            Pic.ScreenLoad ("Sprites/Axeman/map.bmp", i * 20, j * 20, picCopy);
        end if
    end for
end for

View.Update




%4rth file :AxemanFight.t


EnemyFlag := 0
Pic.ScreenLoad ("Sprites/BGBMP/32.bmp", 0, 185, picCopy)
%Pic.ScreenLoad ("Sprites/hud copy.bmp", 0, 0, picMerge)
Pic.ScreenLoad ("Classes/buttons/hud.bmp", 0, 0, picMerge)

Pic.ScreenLoad ("Classes/buttons/sword.bmp", 350, 30, picMerge) %80x80
Pic.ScreenLoad ("Classes/buttons/hp.bmp", 440, 30, picMerge)
Pic.ScreenLoad ("Classes/buttons/hp.bmp", 530, 30, picMerge)

pic1 := Pic.FileNew ("Sprites/Ephriam/Critical BMP/crit1.bmp")
width := Pic.Width (pic1)
height := Pic.Height (pic1)
pic1 := Pic.Scale (pic1, width * 3, height * 3)
sprite1 := Sprite.New (pic1)
Sprite.SetPosition (sprite1, 400, 240, false)
Sprite.Show (sprite1)

pic2 := Pic.FileNew ("Sprites/Axeman/basic/basic5.bmp")
width := Pic.Width (pic2)
height := Pic.Height (pic2)
pic2 := Pic.Scale (pic2, width * 3, height * 3)
sprite2 := Sprite.New (pic2)
Sprite.SetPosition (sprite2, expos, 240, false)
Sprite.Show (sprite2)

pic3 := Pic.FileNew ("Sprites/Axeman/basic/basic0.bmp")
width := Pic.Width (pic3)
height := Pic.Height (pic3)
pic3 := Pic.Scale (pic3, width * 3, height * 3)
sprite3 := Sprite.New (pic3)

View.Update
delay (1000)

%Heal
for i : 0 .. 13
    healpic (i) := Pic.FileNew ("Sprites/heal/" + intstr (i) + ".bmp")
end for

for i : 0 .. 13
    healsprite (i) := Sprite.New (healpic (i))
end for

%Temp Vars
var hp1 : int := 305
var crit2, crit1 : int
var turn : int := 0
%Axe
for i : 1 .. 5 by 1

    axepic (i) := Pic.FileNew ("Sprites/Axeman/axe/axe" + intstr (i) + ".bmp")
    % width := Pic.Width (crit (i))
    % height := Pic.Height (crit (i))
    %crit (i) := Pic.Scale (crit (i), width * 3, height * 3)
end for

for i : 1 .. 5
    axesprite (i) := Sprite.New (axepic (i))
end for

%Critical
for i : 1 .. 31 by 1

    crit (i) := Pic.FileNew ("Sprites/Ephriam/Critical BMP/crit" + intstr (i) + ".bmp")
    width := Pic.Width (crit (i))
    height := Pic.Height (crit (i))
    crit (i) := Pic.Scale (crit (i), width * 3, height * 3)
end for

for i : 0 .. 8 by 1

    blood1 (i) := Pic.FileNew ("Sprites/blood2/" + intstr (i) + ".bmp")
    blood1 (i) := Pic.Flip (blood1 (i))
    width := Pic.Width (blood1 (i))
    height := Pic.Height (blood1 (i))
    blood1 (i) := Pic.Scale (blood1 (i), width * 3, height * 3)
end for

for i : 1 .. 8 by 1

    crithit (i) := Pic.FileNew ("Sprites/Hit effects/Critical/" + intstr (i) + ".bmp")
end for

pic1 := Pic.FileNew ("Sprites/Ephriam/Critical BMP/crit1.bmp")
width := Pic.Width (pic1)
height := Pic.Height (pic1)
pic1 := Pic.Scale (pic1, width * 2, height * 2)

Sprite.SetPosition (sprite1, 400, 240, false)
Sprite.Show (sprite1)

critpic := Pic.FileNew ("Sprites/Hit effects/Critical/1.bmp")
critfx := Sprite.New (critpic)

%Blood
blood1pic := Pic.FileNew ("Sprites/blood2/0.bmp")
critblood := Sprite.New (blood1pic)

Sprite.SetPosition (critfx, 0, 140, false)
Sprite.SetPosition (critblood, 100, 320, false)

%Basic

for i : 0 .. 21 by 1
    bas (i) := Pic.FileNew ("Sprites/Ephriam/Basic BMP/bas" + intstr (i) + ".bmp")
    width := Pic.Width (bas (i))
    height := Pic.Height (bas (i))
    bas (i) := Pic.Scale (bas (i), width * 3, height * 3)
end for

for i : 0 .. 8 by 1
    hit (i) := Pic.FileNew ("Sprites/Hit effects/Basic/" + intstr (i) + ".bmp")
    blood2 (i) := Pic.FileNew ("Sprites/blood1/" + intstr (i) + ".bmp")
end for

pic1 := Pic.FileNew ("Sprites/Ephriam/Basic BMP/bas0.bmp")
width := Pic.Width (pic1)
height := Pic.Height (pic1)
pic1 := Pic.Scale (pic1, width * 3, height * 3)

Sprite.SetPosition (sprite1, 400, 240, false)
Sprite.Show (sprite1)

baspic := Pic.FileNew ("Sprites/Hit effects/Basic/0.bmp")
basfx := Sprite.New (baspic)

%Blood
blood1pic := Pic.FileNew ("Sprites/blood1/0.bmp")
basblood := Sprite.New (blood1pic)

Sprite.SetPosition (basfx, 0, 90, false)
%Sprite.SetPosition (basblood, 190, 280, false)

%Hp
drawfillbox (335, 162, hp, 172, 40)
drawfillbox (15, 162, hp1, 172, 40)


%MouseWhere
loop
    mousewhere (x, y, button)
    if hp < 336 then
        EnemyFlag := 2
        exit
    end if
    %Enemy HP Modifiers
    if HudClick (x, y, 350, 30, 430, 110) and turn = 0 then

        randint (crit2, 1, 5)
        if crit2 = 1 then
            include "Ephriam/Critical.t"
            hp1 -= weapon * 4
            drawfillbox (15, 162, 305, 172, white)
            drawfillbox (15, 162, hp1, 172, 40)
            if hp1 < 16 then
                EnemyFlag := 1
                exit
            end if
            delay (200)
            locate (1, 1)
            delay (2000)
            randint (crit1, 1, 5)
            if crit1 = 1 then
                include "Axeman/crit.t"
                hp -= 40 - armor
                drawfillbox (335, 162, 625, 172, white)
                drawfillbox (335, 162, hp, 172, 40)

                turn := 0
            else
                include "Axeman/Basic.t"
                hp -= 30 - armor
                drawfillbox (335, 162, 625, 172, white)
                drawfillbox (335, 162, hp, 172, 40)

                turn := 0
            end if

        else
            include "Ephriam/Basic.t"
            hp1 -= weapon
            drawfillbox (15, 162, 305, 172, white)
            drawfillbox (15, 162, hp1, 172, 40)
            if hp1 < 16 then
                EnemyFlag := 1
                exit
            end if
            delay (200)
            locate (1, 1)
            delay (2000)
            randint (crit1, 1, 5)
            if crit1 = 1 then
                include "Axeman/crit.t"
                hp -= 40 - armor
                drawfillbox (335, 162, 625, 172, white)
                drawfillbox (335, 162, hp, 172, 40)

                turn := 0
            else
                include "Axeman/Basic.t"
                hp -= 30 - armor
                drawfillbox (335, 162, 625, 172, white)
                drawfillbox (335, 162, hp, 172, 40)

                turn := 0
            end if
        end if
    end if

    if HudClick (x, y, 440, 30, 520, 110) and turn = 0 and hp < 610 then
        healX := 420
        for i : 0 .. 13
            Sprite.SetPosition (healsprite (i), healX, 230, false)
            Sprite.Show (healsprite (i))
            delay (60)
            Sprite.Hide (healsprite (i))
        end for

        hp += 150
        drawfillbox (335, 162, 625, 172, white)
        drawfillbox (335, 162, hp, 172, 40)
        delay (10)
        locate (1, 1)
        delay (2000)
        randint (crit1, 1, 5)

        if crit1 = 1 then
            include "Axeman/crit.t"
            hp -= 80 - armor
            drawfillbox (335, 162, 625, 172, white)
            drawfillbox (335, 162, hp, 172, 40)

            turn := 0
        else
            include "Axeman/Basic.t"
            hp -= 30 - armor
            drawfillbox (335, 162, 625, 172, white)
            drawfillbox (335, 162, hp, 172, 40)

            turn := 0
        end if
        % elsif HudClick (x, y, 440, 30, 520, 110) and turn = 0 and hp > 610 then
        %       put "You do not have enough missing health to restore hp"
        %      exit
    end if
end loop

if EnemyFlag = 1 then %Emp wins
    Sprite.Free (sprite2)
    Pic.ScreenLoad ("Classes/buttons/hud.bmp", 0, 0, picMerge)
    delay (1000)
    Sprite.Free (sprite1)
    cls
    mapnumber := 2
    include "transition.t"
elsif EnemyFlag = 2 then %Enemy wins
    Sprite.Free (sprite1)
    Pic.ScreenLoad ("Classes/buttons/hud.bmp", 0, 0, picMerge)
    delay (1000)
    Sprite.Free (sprite2)
    cls
    mapnumber := 2
end if




Please specify what version of Turing you are using
4.11
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun Jan 24, 2016 7:58 am   Post subject: RE:Error At Non-existent If Loop

It's likely you have a syntax error wherever you include 'mapcreation.t'. You didn't post that line of code here though, so I can't tell for sure.

Furthermore, I strongly suggest you stop using processes entirely and switch to procedures. Processes are difficult to control properly and will cause serious bugs that are very difficult to identify and fix.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: