Page 1 of 1

how to add only email adress in field and load it at startup

Posted: Sat Sep 27, 2014 11:10 am
by sphere
Hello,
thanks everyone for all these beautifull solutions we can find here.
So i'm new to Livecode, i have been busy with flowstone, but though there is Ruby in it, still you can't do all you want to do.
And this LiveCode seems easier than Ruby. But i'm stock with some questions, and i will not set them here all at once.
I searched a lot but can't find.

I have a simple input field. I can put in some text and when i push the button it is being saved to a local text file which i use as a kind of database (I don't want to use a real database on a server). So far so good.
Also new lines adding goes well. And reading the file in a scrolling field right after it has been saved also is working.

1. How do i get it that only email adresses can be added and nothing else?
This is the button script:

Code: Select all

on mouseUp
put field "New Email Adress" & cr before field "email list"
    put field "email list" into URL ( "file:" & specialFolderPath("Documents") & slash & "emailadresses.txt" )
end mouseUp

2. how should the script be in the stack to open the text file when starting? (the first time it does not exist of course, the text file is made after first input)
i have this but its not working

Code: Select all

if exist then put URL ( "file:" & specialFolderPath("Documents") & slash & "emailadresses.txt" ) into field "List of email addresses"
Thanks for any help on this :)

Re: how to add only email adress in field and load it at sta

Posted: Sat Sep 27, 2014 11:21 am
by sphere
ok
first part i allready have (it was actually quite simple)
i added before the put lines this :

Code: Select all

if field "New Email Adress"contains "at blabla dot kom" then

and after the put lines this

Code: Select all

else answer "Only Email adresses ending on at blabla dot kom are allowed."

Re: how to add only email adress in field and load it at sta

Posted: Sat Sep 27, 2014 12:15 pm
by Klaus
Hi sphere,

1. welcome to the forum! :D

2. Do this:

Code: Select all

on openstack 
## or opencard
  ## Create the filename:
  put specialFolderPath("Documents") & "/emailadresses.txt" into tFile

  ## Now check its existence and act accordingly if present:
  if there is a file tFile then
    put url("file:" & tFile) into tMailAddresses
    ## Do something with tMailAddresses
  end if
end openstack
Check these great stacks to get the basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

Re: how to add only email adress in field and load it at sta

Posted: Sat Sep 27, 2014 2:13 pm
by sphere
Hello Klaus,

Thanks for the Welcome !

I allready really love it to play and work with Livecode :D

I tested your code and changed to the actual names of the files and it runs perfectly ! Thanks very much.

Up to the next step. And if i can't figuring it out by altering some codes and examples i will search for it and alternatively create a new topic.

Thanks for helping me out.

Re: how to add only email adress in field and load it at sta

Posted: Mon Sep 29, 2014 3:49 pm
by zaxos

Code: Select all

on mouseUp
   if fld "New Email Adress" contains "@" then
      if the borderColor of fld "New Email Adress" is "red" then set the borderColor of fld "New Email Adress" to "0,0,0"
      put field "New Email Adress" & cr before field "email list"
   else
      set the borderColor of fld "New Email Adress" to "red"
   end if
end mouseUp

Re: how to add only email adress in field and load it at sta

Posted: Mon Sep 29, 2014 7:16 pm
by sphere
Thanks Zaxos

also very nice!

thank you !