DraftSight Lisp - Blank/Empty Dialog Box Lock - dialog

I'm trying to create a Yes/No/Cancel dialog box in DraftSight by using a tutorial's solution (Link to site). However, when I try to add the first message to the dialog box, the program breaks, and the dialog box opens without any code to close the dialog box. Using task manager to stop DraftSight is the only way I can close the dialog box. Is there an issue with the AutoLisp code that I'm using?
References:
DraftSight/Solidworks Lisp
Lisp code:
;; Source: https://www.afralisp.net/dialog-control-language/tutorials/the-autolisp-message-box.php
;; Lisp code from tutorial
(defun lspYesNoCancel (message1 message2 message3 main)
(setq msgboxPath "C:\\Users\\GarrettB\\Documents\\Visual Studio Code\\DraftSight LISP")
(princ (strcat msgboxPath "\n"))
(princ)
;; Loading the dialoge box file and returning the ID file
(princ "YesNoCancel 01\n")
(setq dcl_id (load_dialog (strcat msgboxPath "\\" "msgbox.dcl")))
(princ "YesNoCancel 02\n")
;; Creating the dialoge box
(if (not (new_dialog "lspYesNoCancel" dcl_id "(done_dialog)")) (exit))
(princ "YesNoCancel 03\n")
(princ dcl_id)(princ "\n")
;; Dialoge Message
(if (set_tile "message1" message1)(princ "Message added to message1\n")(exit))
(princ "YesNoCancel 04-1\n")
(if (set_tile "message2" message2)(princ "Message added to message2\n")(exit))
(if (set_tile "message3" message3)(princ "Message added to message3\n")(exit))
(if (set_tile "main" main)(princ "Message added to main\n")(exit))
(princ "YesNoCancel 04-4\n")
;; Command Buttons
(if (action_tile "no" "(done_dialog) (setq result \"F\")")(princ "No command added\n")(exit))
(if (action_tile "yes" "(done_dialog) (setq result T)")(princ "Yes command added\n")(exit))
(if (action_tile "cancel" "(done_dialog) (setq result nil)")(princ "Cancel command added\n")(exit))
(princ "YesNoCancel 05\n")
;; Interaction
(exit)
(quit)
;; (start_dialog) ;----; Show dialog box
(unload_dialog dcl_id) ; Closes the link to the .dcl file
(princ)
)
dcl code:
lspYesNoCancel : dialog {
key = "main";
: column {
: text {Key = "message1";}
: text {key = "message2";}
: text {key = "message3";}
}
: row {
: spacer {width = 1;}
: button {
label = "Yes";
key = "yes";
width = 12;
fixed_width = true;
mnemonic = "Y";
is_default = true;
}
: button {
label = "No";
key = "no";
width = 12;
fixed_width = true;
mnemonic = "N";
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer {width = 1;}
}
}

In the line : text {Key = "message1";}, Key needs to have a lowercase "k." Therefore this : text {key = "message1";} is the right answer.

Related

Update object's text in Solar2D (ex-CoronaSDK)

I want to display a text with a number and to update the number when pressing a button. Here is what I got right now:
local oxyPar = 10
--the oxyPar is just a number
local oxyOpt =
{
text = "Oxygen: ".. tostring( oxyPar )
--all other text parameters
}
local oxygen = display.newText( oxyOpt )
--display a text calling oxyOpt table for the parameters
local timeOpt =
{
--all the button parameters
onRelease = timeOn
--call timeOn function on the button release
}
local timeBtn = widget.newButton( timeOpt )
--a button that calls timeOpt table for the parameters
local function timeOn( listener )
oxyPar = oxyPar + 1
end
After pressing the button the oxyPar (the number) should grow by one, but the text still shows up Oxygen: 10 instead of Oxygen: 11. Is there a way to update the text so it shows the new number?
changing oxyPar does not affect your display object oxygen.
A number value is copied by value so
local oxyPar = 10
local oxyOpt = {text = tostring(oxyPar)}
local oxygen = display.newText( oxyOpt )
is equivalent to
local oxyOpt = {text = "10"}
local oxygen = display.newText( oxyOpt )
There is no relation between oxyPar and oxyOpt as you simply copied the return value of tostring(10) into oxyOpt.text which is a different variable.
Change ogygen.text instead
Please refer to the Solar2d reference manual.
https://docs.coronalabs.com/api/library/display/newText.html
Updating Text Post-Creation
local myText = display.newText( "hello", 100, 200, native.systemFont, 12 )
myText:setFillColor( 1, 0, 0.5 )
-- Change the displayed text
myText.text = "Hello World!"

InstallShield Custom Dialog, WaitOnDialog() always return -1 (DLG_ERR)

I'm currently doing a Custom Dialog to handle locked file situation on an InstallScript project. I know there are built-in functions like SdException() to handle this case but this is a requirement to avoid the case where user accidentally chose to ignore the situation.
In summary, I initialize the EzDefineDialog() and then call WaitOnDialog() to display the dialog but it always returns -1.
The following is my code:
prototype NUMBER LockedFile(string /*FilePath*/);
//[[ ID_DATA
#define IDD_VER 300
#define ID_NAME_LOCKED_FILE "LockedFile"
#define ID_TITLE_LOCKED_FILE "Default Dialog Title\nDefault Title message"
#define ID_TEMPLATE_LOCKED_FILE 12345
//]]
//[[ ID_SYMBOLS
#define BT_PostPone 1303
#define BT_Retry 1304
#define BT_Abort 1305
#define IDC_TEXT1_LOCKED_FILE 1301
//]]
function NUMBER LockedFile(szFile /*FilePath*/)
NUMBER nId; // contains the return code of WaitOnDialog
NUMBER nResult; // contains the return code of LockedFile
BOOL bDone; // tells if the dialog is to be closed
INT hwndDlg; // the handle of the dialog itself
STRING szTitle; // dialog's title
STRING szDlg; // the name of the dialog
STRING szMessage; // message to display on dialog
NUMBER nTemplate; // variable to store the template to be used for this dialog
begin
// Specify a name to identify the custom dialog in this installation.
szDlg = ID_NAME_LOCKED_FILE;
nTemplate = ID_TEMPLATE_LOCKED_FILE;
if (EzDefineDialog (szDlg, ISUSER, "", nTemplate) = DLG_ERR) then
MessageBox("Fail to initialize the Locked Dialog for "+szFile, SEVERE);
abort;
endif;
bDone = FALSE;
while (!bDone)
nId = WaitOnDialog(szDlg);
switch (nId)
case DLG_INIT:
// first internal InstallShield intitialise
hwndDlg = CmdGetHwndDlg( szDlg );
SdGeneralInit(szDlg, hwndDlg, 0, "");
case DLG_CLOSE:
// The user clicked the window's Close button.
Do (EXIT);
case DLG_ERR:
MessageBox ("Unable to display dialog. Setup canceled.", SEVERE);
abort;
case BT_PostPone:
// user clicked PostPone button, the operation will be carried out after reboot
bDone = TRUE;
nResult = 1;
case BT_Retry:
// user clicked retry button, retry the operation immediately
bDone = TRUE;
nResult = 2;
case BT_Abort:
// user clicked abort button, abort the installation
bDone = TRUE;
nResult = 3;
default:
// user do something else
bDone = TRUE;
nResult = -1;
endswitch;
endwhile;
EndDialog(szDlg); // Close the dialog box.
ReleaseDialog(szDlg); // Free the dialog box from memory.
return nResult;
end;
I have double checked and make use that the ISResourceID in both Dialogs and Direct Editor to be 12345, which was passed into EzDefineDialog (szDlg, ISUSER, "", nTemplate) as nTemplate. The Dialog name (szDlg) is also double checked.
I want to know where I did wrong. How can I display my Custom Dialog ?
I had a similar experience, I referenced the dialog by its name, not resourceID. The WaitOnDialog() function always returned DLG_ERR until I changed the dialog's resourceID to 0.
Perhaps this helps...

Trying to use a xpages dynamic view panel with search on fields value

I have created an xPages custom control based on Dynamic View Panel. I then added 2 comboboxes filled with various values (States, Departments) and an editbox field and a Search button. I then coded the follow to return the search string onto a computed "Search in view results" for the panel.
var tmpArray = new Array("");
var cTerms = 0;
if(viewScope.categoryText1 != null) {
if ( viewScope.categoryText1.trim() != "") {
tmpArray[cTerms++] = "(FIELD State CONTAINS \"" + viewScope.categoryText1 + "\")";
}
}
if(viewScope.categoryText2 != null ){
if ( viewScope.categoryText2.trim() != "") {
tmpArray[cTerms++] = "(FIELD Department = \"" + viewScope.categoryText2 + "\")";
}
}
if(viewScope.searchString != null ) {
if ( viewScope.searchString != "") {
tmpArray[cTerms++] = "( \"" + viewScope.searchString + "\")";
}
}
qstring = tmpArray.join(" AND ").trim();
viewScope.queryString = qstring; // this just displays the query
return qstring // this is what sets the search property
The search works for the editbox field values but not for the strings generated by the comboboxes: 'FIELD State CONTAINS "some state"' or 'FIELD Department = "some deptname"'. These search strings return an empty view.
The Column names match the underlying Notesview (both programmatically and column title).
I think this might have something to do with what are the column names surfaced by the Dynamic View Panel but I'm not sure.
Full text search looks in document fields for search strings, not in column values.
So, make sure fields State and Department contain the strings you are looking for.
Do you use aliases? Maybe you save abbreviation for State in document only but user can select State's full name for search...

Autoit controls

I use ControlSend() to send hotkeys in a different window. Problem is to find the right window control. Or the control is right and there is an unknown issue. These are the controls:
Title: PokeMMO
Class: LWJGL
controlID: still unknown
Process: javaw.exe
$handle = WinGetHandle("[TITLE:PokeMMO; CLASS:LWJGL]")
ControlSend($handle, Default, $handle, "{Down}")
Didn't work.
Global $sProcess = "javaw.exe" ; Process PokeMMO
ControlSend(_Process2Win($sProcess), "", "", "{DOWN}")
Func _Process2Win($pid)
If IsString($pid) Then $pid = ProcessExists($pid)
If $pid = 0 Then Return -1
$list = WinList()
For $i = 1 To $list[0][0]
If $list[$i][0] <> "" And BitAND(WinGetState($list[$i][1]), 2) Then
$wpid = WinGetProcess($list[$i][0])
If $wpid = $pid Then Return $list[$i][0]
EndIf
Next
Return -1
EndFunc ;==>_Process2Win
Didn't work. I also tried this:
Run("C:\path\path\path\PokeMMO.exe")
WinWait("[CLASS:LWJGL]")
Local $sControl = ControlGetFocus("[CLASS:LWJGL]")
MsgBox(0, "ControlGetFocus Example", "The control that has focus is: " & $sControl)
Stystem Message: Java Virtual Machine Launcher - A Java Exception has occured ERROR!
A guide on YouTube tells to install a different version of Java.
Try using Title and text parameter, but leave the controlID parameter free like "" or ''. That should also work. Good luck.

How to properly link DCL to AutoLisp?

I'm trying to build a very basic AutoLisp interface. I'm a total beginner at this, so after failing to code this from scratch, I turned to studying DCL properly. I followed this tutorial:
http://www.afralisp.net/dialog-control-language/tutorials/dialog-boxes-and-autolisp-part-1.php
And I got the same error. AutoCAD basically exits from executing the function, as if the dcl file wasn't even there.
I tried typing the address completely into it, but I think it should be able to work simply like linking HTML to images found in the same folder.
Below you have my code:
DCL:
samp1 : dialog {
label = "Structural Holes";
ok_cancel;
}
Lisp:
(defun C:samp1()
(setq dcl_id (load_dialog "samp1.dcl"))
(if (not (new_dialog "samp1" dcl_id))
(exit)
)
(action_tile
"cancel"
"(done_dialog)(setq userclick nil)"
)
(action_tile
"accept"
"(done_dialog)(setq userclick T))"
)
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
(princ)
Thanks to anyone who will take the time to help me out with this. I'm starting to be quite desperate and it's my first and only autolisp project, so I have no experience whatsoever...
LE: Please note that the dcl file and the lisp file are both found in the same folder, no other subfolders or anything else.
Could not find **.DCL file
error: quit / exit abort
error: LOAD failed
This usually means the autolisp file or DCL file could not be found. To solve this problem, make sure you put your autolisp and DCL files inside the AutoCAD search path. To be more specific, put them in a directory that is part of your "Support File and Search Path". To find the AutoCAD support file and search path list, do the following:
In AutoCAD, click on the TOOLS drop down menu.
Go to the OPTIONS menu item.
Click on the FILES tab.
Click on the plus sign + in front of SUPPORT FILE AND SEARCH PATH.
This is your search path location. The directories listed there are searched in order, from top to bottom for any autolisp program you try to load. It is also used to find blocks and DCL files.
Either add the directory you store your autolisp and DCL files, or move your autolisp and DCL files into one of the directories listed here. This should end the errors listed above.
I came across this piece of information by accident here:
http://www.jefferypsanders.com/autolisp_nodcl.html
HUGE THANKS to JefferyPSanders for that......
For what its worth, you can also create a dialog on the fly in a "known directory" (like the directory AutoCAD resides in for example). The following will demonstrate that.
(defun _make-getstring-dialog-on-the-fly ( / fn f dcl dcl_id userclick str)
(setq fn (strcat
(vl-filename-directory
(findfile "acad.exe")) "\\$vld$.dcl")
f (open fn "w")
dcl
'(
"stringdlg : dialog {"
"label = \"Charater Array\";"
": edit_box {"
"label = \">>:\";"
"edit_width = 20;"
"key = \"stringdlg\";"
"is_default = true;"
"}"
": row {"
"alignment = centered;"
"fixed_width = true;"
" : button {"
" label = \"OK\";"
" key = \"dcl_accept\";"
" width = 10;"
" allow_accept = true;"
" }"
"}"
"}"
)
)
(mapcar
(function
(lambda ( x )
(write-line x f)
(write-line "\n" f)))
dcl)
(close f)
(setq dcl_id (load_dialog fn))
(new_dialog "stringdlg" dcl_id)
(action_tile "stringdlg" "(setq str $value)(done_dialog)")
(setq userclick (start_dialog))
(unload_dialog dcl_id)
str
)

Resources