Working with @UIDialog

For requesting general information about EViews, sharing your own tips and tricks, and information on EViews training or guides.

Moderators: EViews Gareth, EViews Moderator

madm
Posts: 19
Joined: Mon Oct 23, 2017 1:13 pm

Working with @UIDialog

Postby madm » Thu Nov 09, 2023 6:15 pm

I have found the @uidialog function quite cumbersome to work with so I came up with a slightly more manageable subroutine.

Code: Select all

subroutine add_dialog_item(string %DIALOG, string %TYPE, string %IOVAR, string %PROMPT, string %OPTION_LIST, scalar !MAX_EDIT_LENGTH) ' Adds a dialog item to a string dialog spec. The item can be one of: ' Edit field: "Edit", IO_String, prompt_string[, max_edit_length] ' Listbox: "List", IO_StringOrScalar, prompt_string, list_string ' Radio buttons: "Radio", IO_Scalar, prompt_string, list_string ' Checkbox: "Check", IO_Scalar, prompt_string ' Text: "Text", text_string ' Caption: "Caption", caption_string ' Column break: "Colbreak" ' OK Button: "Button", button_string ' Cancel Button: "Buttonc", button_string ' Subroutine arguments: ' %DIALOG - Name of the dialog to fill ' %TYPE - One of "Edit", "List", "Radio", "Check", "Text", "Caption", "Colbreak", "Button", "Buttonc" ' %IOVAR - Name of the control variable enclosed in quotes (don't pass the variable itself!!) -- for an Edit control this will contain the text entered in the control (e.g., "%NAME") or fore a checkbox it contains the name of the scalar contained the result (e.g. "!CHECK"), 0=unchecked or 1=checked ' %PROMPT - The string argument (description, prompt etc.) ' %OPTION_LIST - The options for the List or Radio control as a space separated list ' !MAX_EDIT_LENGTH - The maximum length of text that can be entered in the EDIT control if @trim(%DIALOG)<>"" then %DIALOG = %DIALOG + "," + """" + %TYPE + """" else %DIALOG = """" + %TYPE + """" endif if %IOVAR<>"" then %DIALOG = %DIALOG + "," + %IOVAR endif if %PROMPT<>"" then %PROMPT = @replace(%PROMPT, """", "'") %DIALOG = %DIALOG + "," + """" + %PROMPT + """" endif if %OPTION_LIST<>"" then 'TODO: This won't work as soon as you have space chars in the options %DIALOG = %DIALOG + "," + """" + %OPTION_LIST + """" endif if !MAX_EDIT_LENGTH>0 then %DIALOG = %DIALOG + "," + @str(!MAX_EDIT_LENGTH) endif endsub

Here's an example of how to use it:

Code: Select all

logmode l %DIALOG_DATA = "" %TEXT = "A string of text" %NAME = "<name goes here>" !CHECK = 0 !RADIO = 2 %RADIO_OPTIONS = "High Medium Low" call add_dialog_item(%DIALOG_DATA, "Caption", "", "My first dialog", "", 0) call add_dialog_item(%DIALOG_DATA, "Text", "", %TEXT, "", 0) call add_dialog_item(%DIALOG_DATA, "Edit", "%NAME", "A text entry", "", 0) call add_dialog_item(%DIALOG_DATA, "Button", "", "A button", "", 0) call add_dialog_item(%DIALOG_DATA, "Check", "!CHECK", "A checkbox", "", 0) call add_dialog_item(%DIALOG_DATA, "Colbreak", "", "", "", 0) for %g one two three call add_dialog_item(%DIALOG_DATA, "Button", "", "", "OPTION "+%g, 0) next call add_dialog_item(%DIALOG_DATA, "Radio", "!RADIO", "A radio group", %RADIO_OPTIONS, 0) !result = @uidialog({%DIALOG_DATA}) logmsg RESULT=!result NAME=%NAME CHECK=!CHECK RADIO=!RADIO

Return to “General Information and Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest