answer file dialog not recognizing cancel - livecode

Why does this cancel check not work?
answer file "Bitte Bild auswählen" with type "Images|jpg|jpeg|png"
if the result is not "cancel" then
put it into tMyImagePath
...
end if
It always starts to run code. I also tried "Cancel" and "Abbrechen". I am using MacOSX in German and LiveCode 6.6.2 RC3.

Just replace "the result" with "it" and it should work.
The user response of an answer dialog is stored in the variable "it".
Btw, pressing "cancel" in an "answer file" dialog does return nothing to the variable "it"
So you could change your script like this
answer file "Bitte Bild auswählen" with type "Images|jpg|jpeg|png"
if it is not empty then put it into tMyImagePath
...
end if

If you want to use 'the result' you can also do this:
answer file "Bitte Bild auswählen" with type "Images|jpg|jpeg|png"
if the result is not empty then
put it into tMyImagePath
...
end if

Related

Syntax problem to check if boxed are filled with information

i think i have a syntax problem.
I just want to check with vba if theres every field filled for next steps.
I need like 15 more cells to check
Maybe someone can help me
my code work, just the first line give error because of this "and ("C24:C22")"
For Each Zellen_auf_Inhalt_prüfen In Range("B7:J7") **and ("C24:C22")**
If Zellen_auf_Inhalt_prüfen.Value = "" Then
MsgBox "Bitte alle Zellen ausfüllen."
GoTo MacroEnde
End If
Next Zellen_auf_Inhalt_prüfen
"Zellen auf inhalt prüfen" means, to check cells if theres anything in
i google but i dont find any solution.
I think you are looking for the union statement:
For Each Zellen_auf_Inhalt_prüfen In Union(Range("B7:J7"), Range("C24:C22"))

Login form have some problems

I am beginner in Livecode. I got some code for log in. My problem is I want to convert the password to "*" How i change the following code
local sUsername, sPassword
on openCard
put "johnsmith" into sUsername
put "pa55word" into sPassword
end openCard
on loginCheck
if field "username" is sUsername and field "password" is sPassword then
answer "Login Successful"
go to card "accessed"
else
answer "Details Incorrect. Please try again!"
end if
end loginCheck
One simple method is to use the keyDown message along with a custom property to store the clear text. Place the following code in the password field's script:
on keyDown theKey
-- RESTRICT THE ALLOWED KEYS TO SOME DEFINED CHARACTERS
if theKey is not in "abcdefghijklmnopqrstuvwxyz1234567890" then exit keyDown
put the hiddenText of me into temp
put theKey after temp
set the hiddenText of me to temp
put "*" after me
end keyDown
on backspaceKey
set the hiddenText of me to empty
set the text of me to empty
end backspaceKey
The second line in the keyDown handler lets you limit the characters that are accepted for the password to a defined list (you could include special characters such as "#" and "_" and others if you wish). The backspaceKey handler is used to delete any entered characters and start over.
Note that you may want to handle special cases such when the enterKey and/or returnKeys are pressed, which often trigger the submission of a form.

How to adding and append code on runtime ? - livecode

I want to add code and append it on runtime.
Example:
This code is before adding code on runtime
on opencard
emptyvariable
end opencard
command selectvdofile
answer file "Select Video file"
put it into fld "txt_namefile"
put it into namefile
end selectvdofile
This code is after adding code on runtime
on opencard
emptyvariable
-------------------------
put "test" into TestV << This line
end opencard
command selectvdofile
answer file "Select Video file"
put it into fld "txt_namefile"
put it into namefile
end selectvdofile
Anyone can show exmple code for me ?
Here's an example. Best to save your stack before testing!
on mouseUp
local tScript, tLine
put the script of card "MyCard" into tScript
put lineOffset("end opencard", tScript) into tLine
if tLine > 0 then
put format("put \"test\" into TestV") & LF before line tLine of tScript
set the script of card "MyCard" to tScript
end if
end mouseUp

How print PDF with hyperLink

I try to print PDF with HyperLink, without succes
I have a lock field "etat" with data
Data are formatted like:
Code TAB Nom TAB Adress TAB Ville
56 Eric rue caboteur ST NAZAIRE
87 Franc rue Midin ST brevin
etc
the textStyle of item 3 "Adress" set to "Link and linktext set to ""http://maps.google.fr/maps?f=q&hl=fr&q=theadresse""
When i click on hyperlink item in field "etat" that work fine
Now i would like have the same result after printing this field in PDF
I use this code for printing
on mouseUp
local theResult,thepDF
ask file "" with type "PDF file|pdf|PDF "
if it = "" then
exit mouseUp
end if
put it into thePDF
put the htmltext of fld "etat" into theResult
--set the fileType to "revoPDF "
open printing to pdf thePDF
revPrintField the name of field "etat"
--revPrintText theResult,"<%pageNumber%> of <%numPages%>","<%pageNumber%> of <%numPages%>",the long id of field "etat" of stack "CDH"
close printing
end mouseUp
I have a nice PDF with clicked words, but the click don't launch google maps
The dictionary say for command "print link"
"When printing fields, any text that has its linkText property set together with the link textStyle is treated as if a print link command had been executed with the contents of the property as link, and the formattedRect of the text as rectangle."
But no work.... I have a big headache
Thank for yours help to achieve this
Eric
I am trying to understand your problem and reading through your code, I think maybe the link text…
"http://maps.google.fr/maps?f=q&hl=fr&q=theadresse"
should be…
"http://maps.google.fr/maps?f=q&hl=fr&q=" & theadresse
This is assuming theadresse is a variable containing a valid address to search in Google.

autohotkey assign a text expression to a variable

In an autohotkey script I was trying to assign a text string to a variable. Can anyone spot why this doesn't work, it looks just like some provided examples? I don't need the variable anymore, but now I'm just curious what I did wrong...
myvar := % "foo" ; creates global variable myvar, but has no contents
I know you could just say myvar = foo
but leaving quotes off a fixed text string just makes me cringe. I even had it working but didnt' save my file before making 'a few harmless cosmetic edits.' I click on the "H" task
icon near the clock, use menu File / show variables to verify the empty contents...
Okay, so we assign a value to a variable:
eval_this:= "harry"
If you do it this way, you just read the contents of the variable:
msgbox %eval_this% ;=harry
Of course, here, the text is not evaluated - "eval_this" is just text to ahk:
msgbox eval_this ;= eval_this
This method is called a "Forced Expression" - which is what you are looking to do. It tries to read the text string as if it were code. It isn't reading the contents of any variable, it is looking at the text and forcing it to become a variable (it's sort of the same thing, but not really)
msgbox % eval_this ;= harry
This also gets us harry, and you can see how we are reading the variable:
test := eval_this
msgbox %test% ;=harry
Same thing, different approach (forcing the text to become a variable):
test = % eval_this
msgbox %test% ;=harry
Consider this, where we force both text strings into their actual values
eval_this := "harry"
this_too := " and bob"
test = % eval_this this_too
msgbox %test% ;= harry and bob
Okay, now that you've got all that, here is a practical application. We will force the value of the text string to be a variable. Since we've actually defined what "alert" is, then the gosub will call that definition. Pop this into a script and run it:
eval_this := "alert"
gosub % eval_this
exit ;we are finished with the demo, so end here
alert:
msgbox harry
return

Resources