Indigo Rose Software

Go Back   Indigo Rose Software Forums > AutoPlay Media Studio 7.5 > AutoPlay Media Studio 7.5 Examples

Reply
 
Thread Tools Display Modes
  #1  
Old 09-27-2006
Worm Worm is offline
Indigo Rose Customer
 
Join Date: Jul 2002
Location: USA
Posts: 3,937
Function: Filter Key Press for On Key Event

Just a little function I threw together to filter allowed characters in a input box.

Code:
function FilterKeyPress(InputObject, e_Key, sAllowed)
	sOrig = Input.GetText(InputObject)
	sFilter = String.TrimLeft(sOrig, sAllowed)
	sFilteredLeft = String.TrimLeft(sOrig, sFilter)
	sFilteredRight = String.TrimRight(sFilteredLeft, sFilter)
	Input.SetText(InputObject, sFilteredRight)
	
	Input.SetSelection(InputObject, String.Length(Input.GetText(InputObject)) + 1, String.Length(Input.GetText(InputObject)))
end
Example calls (Should be in the On Key Event)
Code:
-- allow only numerics
FilterKeyPress(this, e_Key, "1234567890")
Code:
-- allow only Capital Letters
FilterKeyPress(this, e_Key, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Reply With Quote
  #2  
Old 09-28-2006
JimS's Avatar
JimS JimS is offline
Forum Member
 
Join Date: May 2003
Location: Pendleton, Oregon
Posts: 911
Good one, thanks Worm. This looks like one that will probably come in handy some time.

I don’t want to brag, but given enough time, I probably could have written a 30+ line function, that could do nearly the same thing. Additionally, mine would only have a couple of small, and rarely encountered bugs.

Maybe if I keep with this programming stuff long enough, I too can be lazy like that, and cram 30 + lines of code down to 8 or so.

Then again, customers would probably put a higher value on my 8.4MB program, than they would on your 1.3MB program. And they should, because I can guarantee that it would take me longer to write my 8.4MB program, than you’d spend writing a 1.3MB program, even if your program had more features, and didn’t crash like mine does, on months with 31 days.

Thanks again Man!
__________________
Add-ons for AMS. Toolbar Buttons Galore, System Animations, the Window Construction Kit, and more.
Visit Acme-Tek
Reply With Quote
  #3  
Old 09-28-2006
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,059
This is why I also request for the addition into of AMS for checking patterns. (aka. 0-9, a-z, A-Z). Lua support this, we just need AMS to catch up via an Action for this basic but important, useful activity.

__________________
Intrigued
www.amsuser.com
Reply With Quote
  #4  
Old 09-28-2006
Lorne's Avatar
Lorne Lorne is offline
Indigo Rose Staff Member
 
Join Date: Feb 2001
Location: Indigo Rose Software
Posts: 2,588
You mean like supporting regexp? It's built into lua, so it's already there in autoplay.

See string.find(), string.gfind(), etc.
__________________
--[[ Indigo Rose Software Developer ]]
Reply With Quote
  #5  
Old 09-28-2006
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,059
I did not have ultimate success with Patterns, it may have been my fault or?:

Quote:
Patterns

A character class is used to represent a set of characters. The following combinations are allowed in describing a character class:

* x (where x is not one of the magic characters ^$()%.[]*+-?) --- represents the character x itself.
* . --- (a dot) represents all characters.
* %a --- represents all letters.
* %c --- represents all control characters.
* %d --- represents all digits.
* %l --- represents all lowercase letters.
* %p --- represents all punctuation characters.
* %s --- represents all space characters.
* %u --- represents all uppercase letters.
* %w --- represents all alphanumeric characters.
* %x --- represents all hexadecimal digits.
* %z --- represents the character with representation 0.
* %x (where x is any non-alphanumeric character) --- represents the character x. This is the standard way to escape the magic characters. Any punctuation character (even the non magic) can be preceded by a `%´ when used to represent itself in a pattern.

* [set] --- represents the class which is the union of all characters in set. A range of characters may be specified by separating the end characters of the range with a `-´. All classes %x described above may also be used as components in set. All other characters in set represent themselves. For example, [%w_] (or [_%w]) represents all alphanumeric characters plus the underscore, [0-7] represents the octal digits, and [0-7%l%-] represents the octal digits plus the lowercase letters plus the `-´ character.

The interaction between ranges and classes is not defined. Therefore, patterns like [%a-z] or [a-%%] have no meaning.

* [^set] --- represents the complement of set, where set is interpreted as above.

For all classes represented by single letters (%a, %c, etc.), the corresponding uppercase letter represents the complement of the class. For instance, %S represents all non-space characters.

The definitions of letter, space, and other character groups depend on the current locale. In particular, the class [a-z] may not be equivalent to %l. The second form should be preferred for portability.

A pattern item may be

* a single character class, which matches any single character in the class;
* a single character class followed by `*´, which matches 0 or more repetitions of characters in the class. These repetition items will always match the longest possible sequence;
* a single character class followed by `+´, which matches 1 or more repetitions of characters in the class. These repetition items will always match the longest possible sequence;
* a single character class followed by `-´, which also matches 0 or more repetitions of characters in the class. Unlike `*´, these repetition items will always match the shortest possible sequence;
* a single character class followed by `?´, which matches 0 or 1 occurrence of a character in the class;
* %n, for n between 1 and 9; such item matches a substring equal to the n-th captured string (see below);
* %bxy, where x and y are two distinct characters; such item matches strings that start with x, end with y, and where the x and y are balanced. This means that, if one reads the string from left to right, counting +1 for an x and -1 for a y, the ending y is the first y where the count reaches 0. For instance, the item %b() matches expressions with balanced parentheses.

A pattern is a sequence of pattern items. A `^´ at the beginning of a pattern anchors the match at the beginning of the subject string. A `$´ at the end of a pattern anchors the match at the end of the subject string. At other positions, `^´ and `$´ have no special meaning and represent themselves.

A pattern may contain sub-patterns enclosed in parentheses; they describe captures. When a match succeeds, the substrings of the subject string that match captures are stored (captured) for future use. Captures are numbered according to their left parentheses. For instance, in the pattern "(a*(.)%w(%s*))", the part of the string matching "a*(.)%w(%s*)" is stored as the first capture (and therefore has number 1); the character matching . is captured with number 2, and the part matching %s* has number 3.

As a special case, the empty capture () captures the current string position (a number). For instance, if we apply the pattern "()aa()" on the string "flaaap", there will be two captures: 3 and 5.

A pattern cannot contain embedded zeros. Use %z instead.
__________________
Intrigued
www.amsuser.com
Reply With Quote
  #6  
Old 09-28-2006
Lorne's Avatar
Lorne Lorne is offline
Indigo Rose Staff Member
 
Join Date: Feb 2001
Location: Indigo Rose Software
Posts: 2,588
regexp patterns can be tricky to learn. That's why there isn't an IR action for it. It's built in, and it works, but if you don't already know how to do regexp searches...it's way beyond what we can reasonably support.
__________________
--[[ Indigo Rose Software Developer ]]
Reply With Quote
  #7  
Old 09-28-2006
TJ_Tigger's Avatar
TJ_Tigger TJ_Tigger is offline
Indigo Rose Customer
 
Join Date: Sep 2002
Location: Sol 3
Posts: 3,188
Find a good UNIX book. They usually have a chapter on how to use regular expressions. They come in quite handy.

Tigg
__________________
TJ-Tigger
"A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
"Draco dormiens nunquam titillandus."
Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine
Reply With Quote
  #8  
Old 09-28-2006
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,059
Quote:
Originally Posted by Lorne View Post
regexp patterns can be tricky to learn. That's why there isn't an IR action for it. It's built in, and it works, but if you don't already know how to do regexp searches...it's way beyond what we can reasonably support.
Ah ha. We have stumped you guys/gals. I knew with some elbow grease, tissue paper, and three widgets it could be done.

__________________
Intrigued
www.amsuser.com
Reply With Quote
  #9  
Old 08-02-2007
FoxLeader's Avatar
FoxLeader FoxLeader is offline
Forum Member
 
Join Date: Nov 2006
Location: Quebec, Canada.
Posts: 432
Hey! Thanks a lot Worm! I worked a long time to have something different, but with the same goal, to work, so I'll probably learn a lot from this!

Thanks again
FoxLeader
Reply With Quote
  #10  
Old 08-02-2007
crz crz is offline
Forum Member
 
Join Date: Jul 2007
Posts: 5
Star issue

does anybody knows how i can get a pagejump when
3 images are visable on a page

can someone please help me with this it's like i can't sleep untill i get it done
and i tried untill i fell in sleep on my keyboard
so please help me.......

thanx
Reply With Quote
  #11  
Old 08-02-2007
mustafa06's Avatar
mustafa06 mustafa06 is online now
Forum Member
 
Join Date: Jul 2007
Posts: 245
.apz pls
Reply With Quote
  #12  
Old 08-02-2007
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,059
Quote:
Originally Posted by crz View Post
does anybody knows how i can get a pagejump when
3 images are visable on a page

can someone please help me with this it's like i can't sleep untill i get it done
and i tried untill i fell in sleep on my keyboard
so please help me.......

thanx
For this example do the following:

1. create a new empty project

2. add the following code to the "On Preload" of Page1:

Code:
Page.StartTimer(100)
3. add the following code to the "On Timer" of Page1:

Code:
if Image.IsVisible("Image1") and Image.IsVisible("Image2") and Image.IsVisible("Image3") then
	Page.Jump("Page2")
end
4. add three Image objects to the canvas and make sure each have an image loaded into them.

5. add a second page to the project (will be named Page2 by default)

6. add a Lable object and set it's text to "Page 2"

7. click the F5 (Preview) toolbar button to view the project. It should page jump to Page2, right away.
__________________
Intrigued
www.amsuser.com
Reply With Quote
  #13  
Old 08-02-2007
crz crz is offline
Forum Member
 
Join Date: Jul 2007
Posts: 5
fixed

thanx intrigued
i already thought that i asked for something
that was imposseble
i just got home so i'm going to try it out right away...

you really helped me out....
Reply With Quote
  #14  
Old 08-02-2007
crz crz is offline
Forum Member
 
Join Date: Jul 2007
Posts: 5
**** your good
i just tried it and it works perfectly
took me a minute with your help
Reply With Quote
  #15  
Old 01-23-2008
rybosom's Avatar
rybosom rybosom is offline
Forum Member
 
Join Date: Jun 2005
Posts: 24
this function is not working on AMS ver. 7.0
onKey I have
Code:
FilterKeyPress(this, e_Key, "0123456789,-")
and I can type only one digit in input, why?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a slider to show audio posiion in time Randy3265 AutoPlay Media Studio 5.0 16 01-07-2006 09:34 AM
Unable to find software? NigelLacey Visual Patch 2.0 4 10-11-2005 11:35 AM
Another tough one... Interaction between Web and AMS Agent Jones AutoPlay Media Studio 5.0 13 08-18-2005 03:10 PM
How can I know the FS Command name of a movie??? yoske AutoPlay Media Studio 5.0 27 01-01-2005 11:39 PM
Responding to Key Presses Desmond AutoPlay Media Studio 5.0 Examples 0 09-26-2003 10:49 AM


All times are GMT -6. The time now is 03:42 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software