English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 05 February 2014, 20:24   #1
marduk_kurios
move $dff006,$dff180
 
marduk_kurios's Avatar
 
Join Date: Feb 2014
Location: USA
Posts: 66
Very Basic Scripting. Confused.

Hi,

I've been lurking here for a while, it's a great board.

So I have this text editor which ignores a given filename as parameter if the file does not yet exist. So I wrote this simple wrapper:

Code:
.key file
.bra {
.ket }

if "{file}" eq ""
    skip blank
endif

if not exists {file}
    echo >{file}.control ""     ; create empty file for later comparison
    echo >{file} ""             ; create dummy file for editor to open
endif

genam3 {file}
skip check

lab blank
    genam3 

lab check
if exists {file}.control
    cmp {file} {file}.control      ; compare with empty file
    if not warn                    ; if it's the same, delete again (nothing was edited)
        delete {file}
    endif
    delete {file}.control          ; otherwise only delete control file
endif
This should work fine, however it does not delete the .control file and complains that there is an ENDIF missing. I stared on this too long, I don't know what's wrong. Can anyone help?

TIA.
marduk_kurios is offline  
Old 05 February 2014, 22:05   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,002
It works correctly for me. Which version of AmigaDOS do you use?

Can you attach the original file? I used cut & paste from there, but maybe the original file contains some strange character which was removed by the web browser.

Note that your script will fail badly if the file name contains space characters.
thomas is offline  
Old 05 February 2014, 22:17   #3
marduk_kurios
move $dff006,$dff180
 
marduk_kurios's Avatar
 
Join Date: Feb 2014
Location: USA
Posts: 66
I checked for strange characters but will provide the file anyway. I am on AmigaOS 1.3 (kickstart 34.5) This still gives the same error to me (endif missing).

Code:
The files do NOT contain identical datas.
ENDIF missing
if failed returncode 20
EDIT: Also, I am aware that it would break for filenames with spaces. Not planning to break it
Attached Files
File Type: 68k test.68k (308 Bytes, 181 views)
marduk_kurios is offline  
Old 05 February 2014, 23:12   #4
marduk_kurios
move $dff006,$dff180
 
marduk_kurios's Avatar
 
Join Date: Feb 2014
Location: USA
Posts: 66
Found the problem:

Apparently IF/ELSE/ENDIF statements must not be indented.
marduk_kurios is offline  
Old 06 February 2014, 10:59   #5
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,002
Quote:
Originally Posted by marduk_kurios View Post
Found the problem:

Apparently IF/ELSE/ENDIF statements must not be indented.

No, this is not true. Indention is allowed.

The problem is that the last line did not end with a newline character. If you had added an empty line to the end of the file it would have worked.
thomas is offline  
Old 06 February 2014, 11:13   #6
marduk_kurios
move $dff006,$dff180
 
marduk_kurios's Avatar
 
Join Date: Feb 2014
Location: USA
Posts: 66
Oh?

Interesting. I did not realize that. I removed all indenting on a hunch, must have fixed that issue while doing so.
marduk_kurios is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
AmigaDOS scripting resources Photon Coders. System 26 19 March 2018 14:51
UAE Scripting Layer FrodeSolheim support.FS-UAE 15 26 January 2014 15:56
C= 64 BASIC as a Scripting Language Charlie Retrogaming General Discussion 2 17 November 2008 14:23
AmigaDOS 1.3 Scripting Language redblade Coders. General 10 16 August 2008 12:58

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:05.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08825 seconds with 14 queries