Alpha Video Training
Results 1 to 16 of 16

Thread: Why is this occuring?

  1. #1
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Why is this occuring?

    In my script, one option is to edit a file before processing it in another option, the trouble is , it will only work if I include the "ShowVar" statement for the variable ..

    the code in my script:

    Code:
    if left(a_dlg_button,18) = "vLogFileNameEvent_" then
        showFilename = .f.
        if a_dlg_button = "vLogFileNameEvent_popupdone" then
            vLogFileText = get_from_file(vLogFileName)
            showvar(vLogFileText)
            select
                case Len(rtrim(vLogFileText)) = 0
                    ui_msg_box("Error:","File "+file.filename_parse(vLogFileName,"n")+" is Empty",UI_ATTENTION_SYMBOL)
                    ShowEdit = .f.
                    a_dlg_button = ""
                case left(vLogFiletext,1) <> "#"
                    ui_msg_box("Error: ","File "+file.filename_parse(vLogFileName,"n")+" has no Header",UI_ATTENTION_SYMBOL)
                    ShowEdit = .f.
                    a_dlg_button = ""
                case else
                    ShowEdit = if(vOpt="Edit Logging",.t.,.f.)
                    a_dlg_button = ""
            end select
            a_dlg_button = ""
        end if
        a_dlg_button = ""
    end if
    If the showvar statement is excluded the script shows a blank variable, but when it is included the variable shows correctly. I've been stuck on this for weeks now and it is driving me nuts!

    when I created a test version with just this element, it works with or without the showvar statement. "Input Logging" option, just loads the file and does error checking.

    Code:
    dlg_title = "testing"
    showedit = .f.
    showfilename = .f.
    dim vLogFileText as c
    ui_dlg_box(dlg_title,<<%dlg%
    {region}
    (vOpt:Input Logging)(vOpt:Edit Logging)
    {watch=vOpt!vOptEvent}
    {endregion};
    {region22}    
    {condition=(ShowFileName=.t.)}
    {text=16vOpt}: [%p=ui_get_file("Input Log Filename","Log(*.Log)|Text (*.txt)",Filename_Decode("[Logpath]")+"*.log","X");I=$a5_smart_file%.81vLogFilename!vLogFileNameEvent_*]
    {endregion22};
    {region23}
    {condition=ShowEdit=.t.}
    Log: [%mw%.40,18vLogFileText]{sp=2}
    {endregion23}
    %dlg%,<<%code%
    if a_dlg_button = "vOptEvent" then
        showfilename = .t.
        a_dlg_button = ""
    end if
    if left(a_dlg_button,18) = "vLogFileNameEvent_" then
        showFilename = .f.
        if a_dlg_button = "vLogFileNameEvent_popupdone" then
            vLogFileText = get_from_file(vLogFileName)
    '        showvar(vLogFileText)
            select
                case Len(rtrim(vLogFileText)) = 0
                    ui_msg_box("Error:","File "+file.filename_parse(vLogFileName,"n")+" is Empty",UI_ATTENTION_SYMBOL)
                    ShowEdit = .f.
                    a_dlg_button = ""
                case left(vLogFiletext,1) <> "#"
                    ui_msg_box("Error: ","File "+file.filename_parse(vLogFileName,"n")+" has no Header",UI_ATTENTION_SYMBOL)
                    ShowEdit = .f.
                case else
                    ShowEdit =  if(vOpt="Edit Logging",.t.,.f.)
            end select
        end if
        a_dlg_button = ""
    end if
    %code%)
    Any suggestions welcomed.
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  2. #2
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,084

    Default Re: Why is this occuring?

    Hi Graham

    Code:
            vLogFileText = get_from_file(vLogFileName)
           ' showvar(vLogFileText)
           'Try - refresh the value
            vLogFileText = eval(" vLogFileText ")  'or   vLogFileText = replacement_parmeter( vLogFileText,local_variable() )
    and are you sure about this "popupdone" event name is a part of the function from A5?
    if a_dlg_button = "vLogFileNameEvent_popupdone" then
    Last edited by johnkoh; 12-06-2019 at 07:10 AM.

  3. #3
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Re: Why is this occuring?

    the crazy thing is that the same code works fine in a previous incarnation of my script! using popupdone (found this was only way of getting file. discovered it whilst using trace.writeln(a_dlg_button) to what was happening.
    I have since copied and pasted the code from the old script (where it worked) into the new, but still get the same result !!
    Last edited by Graham Wickens; 12-06-2019 at 12:14 PM. Reason: aditional info
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  4. #4
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,711

    Default Re: Why is this occuring?

    I tried your script with a text file that I added the '#' to and it worked fine with the showvar() commented out. I selected the Edit Logging option. The Input Logging option however didn't do anything when I selected the same file...
    Last edited by MoGrace; 12-06-2019 at 02:07 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  5. #5
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Re: Why is this occuring?

    Thanks Robin, "Input Logging" just loads the file and checks the header record, for processing later.

    Code:
    dim shared vEditLogFileText as c
    dim shared vLogFileName as c = "I:\my databases\aviation\logging\*.log"
    ui_dlg_box("test",<<%dlg%
     [%p=ui_get_file("Open Filename","Log(*.Log)",vLogFileName,"X");I=$a5_smart_file%.81vLogFilename!vLogFileNameEvent_*];
    Log: [%mw%.40,18vEditLogFileText]{sp=2}
    %dlg%,<<%code%
    if left(a_dlg_button,18) = "vLogFileNameEvent_" then
    	if a_dlg_button = "vLogFileNameEvent_popupdone" then
    		ShowFileName = .f.
    		vEditLogFileText = get_from_file(vLogFileName)
    		select
    			case len(rtrim(vEditLogFileText)) = 0
    				ui_msg_box("Error","File is Empty",UI_ATTENTION_SYMBOL)
    			case left(vEditLogFileText,1) <> "#"
    				ui_msg_box("Error","File has no Header",UI_ATTENTION_SYMBOL)
    		end select
    		showEdit = .t.
    		a_dlg_button = ""
    	end if
    	a_dlg_button = ""
    end if
    
    %code%)
    I changed the Variable name so that is only used in this section.
    I copied the relevant code from my main script as above, which as you found out works fine without the VarShow statement
    going to have a long lie-down in a dark room :)
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  6. #6
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Re: Why is this occuring?

    This gets weirder and weirder!!

    I have split the "Edit Logging" and "Input Logging" into separate code. so you can forget "Input Logging", works just fine.

    Code:
    if left(a_dlg_button,19) = "vEditFileNameEvent_" then
    	showEditFileName = .f.
    	if a_dlg_button = "vEditFileNameEvent_popupdone" then
    		vEditFileText = get_from_file(vEditFileName)
    		trace.writeln(vEditFileText)
    		ShowEdit = .t.
    	end if
    	a_dlg_button = ""
    end if
    the file is still displayed as empty, BUT, the trace write displays correct data ????????????????
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  7. #7
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,711

    Default Re: Why is this occuring?

    Not to be a smart aleck - but did you check the .log file in explorer? Maybe you can add _log to the name and give it a .txt extension instead...
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  8. #8
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Re: Why is this occuring?

    yes, tried it with .txt and same result. The same file used in the "Input Filename" displays the correct data when processed !!
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  9. #9
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,711

    Default Re: Why is this occuring?

    Do you want to see the file displayed when vOpt=Input Logging and the case else statement is triggered?

    Because this statement won't do that since it will always be false:

    ShowEdit = if(vOpt="Edit Logging",.t.,.f.)
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  10. #10
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Re: Why is this occuring?

    I have rewritten this event removing any outside references. The "Input Filename" now has its own event which seems to work, so will leave that alone.

    all I have left is this

    in the dialog

    Code:
    Edit:  [%p=ui_get_file("Edit Filename","Log(*.Log)",vEditLogFileName,"X");I=$a5_smart_file%.81vEditLogFilename!vEditLogFileNameEvent_*];
    
    Log: [%mw%.40,18vEditLogFileText]
    in the code

    Code:
    if left(a_dlg_button,22) = "vEditLogFileNameEvent_" then
    	if a_dlg_button = "vEditLogFileNameEvent_popupdone" then
    		vEditLogFileText = get_from_file(vEditLogFileName)
    		a5_show_variable(vEditLogFileText,"vEditLogFileText")
    	end if
    	a_dlg_button = ""
    end if
    presumably, I have to leave the a5_show_variable in place, to allow the script to run, as I cannot see any other way around it, given my limited experience with xdialog.
    Last edited by Graham Wickens; 12-08-2019 at 06:23 PM. Reason: additional info
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  11. #11
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Re: Why is this occuring?

    it could of course be caused somewhere else in the script, but the only references to the edit file are as above !!
    This is crazy, as it has taken me eleven months to get to a nearly finished script. I have learnt and used all sorts of methods and functions to make the thing work, but not something as simple as this .
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  12. #12
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Re: Why is this occuring?

    even more confusing, below is code from an early version (that works using same test file).

    Code:
    if left(a_dlg_button,18) = "vLogFileNameEvent_" then
    	if a_dlg_button = "vLogFileNameEvent_popupdone" then
    		ShowFileName = .f.
    		vLogFileText = ""
    		vLogFileText = get_from_file(vLogFileName)
    		select
    			case  len(rtrim(vLogFiletext)) = 0
    				ui_msg_box("Error","File is Empty",UI_ATTENTION_SYMBOL)
    				a_dlg_button = ""
    			case left(vLogFiletext,1) <> "#"
    				ui_msg_box("Error","File has no Header",UI_ATTENTION_SYMBOL)
    				a_dlg_button = ""
    		end select
    		a_dlg_button = ""
    		ShowEdit = if(vOpt="Edit Logging",.t.,.f.)
    	end if
    	a_dlg_button = ""
    end if
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  13. #13
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,084

    Default Re: Why is this occuring?

    Graham,

    You have applied
    Code:
    [%p=ui_get_file("Input Log Filename","Log(*.Log)|Text (*.txt)",Filename_Decode("[Logpath]")+"*.log","X");I=$a5_smart_file%.81vLogFilename!vLogFileNameEvent_*]
    and I am not sure you can apply it(Filename_Decode( ) with UI_get_file() or not.

    See my code and is it what you want?

    Code:
    dim defdir as C = "Z:\Temporary"
    
    dlg_title="Open folder"
    ui_dlg_box(dlg_title,<<%dlg%
    {region}
    The next three smart fields are "user defined" smart fields.;
    {endregion};
    {region}
    open folder:| [%p=ui_get_file("Enter file Path"," ",defdir +"\*.*");I=$a5_folder%.81vLogFilename!vLogFileNameEvent_Graham];
    no event:| [%p=ui_get_file("Enter file Path"," ",defdir +"\*.*");I=$a5_folder%.81vTestFilename];
    {endregion};
    <*15&OK>;
    %dlg%,<<%code%
    
    'if left(a_dlg_button,18) = "vLogFileNameEvent_" then  'this event is called from " !vLogFileNameEvent_* " then I assumed A5function code is looking for their own coding
    	'if a_dlg_button = "vLogFileNameEvent_popupdone" then			'this event will not work - A5 may not recognized
    '    if a_dlg_button = "vLogFileNameEvent_change" then 		    'see event name from help, there are few other event name
            'vLogFileText = get_from_file(vLogFileName)				'what is this "Get_from_file()"?
            '
    
    if a_dlg_button = "vLogFileNameEvent_Graham" then	'this event is custom(?) and nothing to do with A5function code
    	
    	
    		if alltrim(vLogFilename) <> "" then
    			'showvar(vLogFilename)
    			ui_msg_box("test: ","File name is "+file.filename_parse(vLogFileName,"n"),UI_ATTENTION_SYMBOL)
    		else
    			msgbox("canceled ")
    		end if
    
     	a_dlg_button = ""
    else if a_dlg_button ="&OK"
    	ui_msg_box("test: ","File name is "+file.filename_parse(vLogFileName,"n"),UI_ATTENTION_SYMBOL)
    	
    	'test no event case
    	ui_msg_box("test no evenet: ","File name is "+file.filename_parse(vTestFileName,"n"),UI_ATTENTION_SYMBOL)
    	a_dlg_button = ""
    end if
    
    %code%)	
    
    
    end

  14. #14
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    795

    Default Re: Why is this occuring?

    Thanks John,
    will have a look.

    Ive been using the "popupdone" event for months and it works every time!!!

    "Get_From_file" is an A5 function

    GET_FROM_FILE()

    Syntax

    Data_String as C = GET_FROM_FILE( Filename as C )

    Argument
    Description

    Filename
    The fully qualified name of a file.


    Description

    GET_FROM_FILE() opens a file specified by filename and reads the contents of the file. Returns a character string with the contents of the file. This high level command is easier than using the low level FILE.OPEN()and <FILE>.READ()methods.

    Supported By

    Alpha Five Version 5 and Above

    Example

    This script sets the value in a variable to the contents of a text file.

    dim text1 as C
    Filename = "f:\a5\test2.txt"
    Text1 = get_from_file(filename)
    dim text1 as C
    Filename = "f:\a5\test2.txt"
    Text1 = get_from_file(filename)

    See Also

    File Functions and Methods, Directory Functions, Save_TO_FILE()


    --------------------------------------------------------------------------------


    The original document is available at http://wiki.alphasoftware.com/GET_FROM_FILE+Function
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  15. #15
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,084

    Default Re: Why is this occuring?

    Thanks

  16. #16
    Member Corelius's Avatar
    Real Name
    Cornelius Koempel
    Join Date
    May 2005
    Location
    Germany, Duisburg
    Posts
    177

    Default Re: Why is this occuring?

    Did you check the variabel scope? Dim shared, dim globale or deleted statements. Just a thought.

Similar Threads

  1. WAS Fatal Error are occuring
    By leetv in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 02-01-2012, 12:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •