search for regular expression in text and put the results into an array

8 messages Options
Embed this post
Permalink
Michael Kann

search for regular expression in text and put the results into an array

Reply Threaded More More options
Print post
Permalink
Here's a script that you might find useful for the XML task.

Put your raw data in fld "a"
Your output will appear in fld "b"
If it is what you need and it isn't perfectly clear how the script works just send me a note and I'll put in some comments.

This is what I have in fld "a" :

When talking about places to eat in Edinburgh Sam mentioned <res>Fishers Bistro</res> but Joe thought that <res>Abstract</res> was the superior eatery. No, Megan replied, <res>Fishers Bistro</res> is where I take all my friends when they visit.

-- put this script in a btn--

on mouseUp
-- put your raw text into fld "a"
-- your output appears in fld "b"

put fld "a" into v
put empty into fld "b"

put "<res>" into  aTag
put "</res>" into bTag

replace return with "*" in v
replace aTag with return in v

replace bTag with "@" in v
filter v with "*@*"

set the itemDelimiter to "@"

put zero into c
repeat for each line curLine in v
put item 1 of curLine into curTeam
put c + 1 && curTeam & cr after original_order
put c into teams_array[curTeam]
add 1 to c
end repeat


delete last char of original_order
put cr & "*** original order ***" & cr into h
put h & cr & original_order & cr after fld "b"

put cr & "*** frequency ***" & cr into h
combine teams_array with cr and space
sort teams_array numeric descending by last word of each
put h & cr & teams_array & cr after fld "b"

end mouseUp


     
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Richard Miller-5

"set the externals" routine for enchanced QT no longer working

Reply Threaded More More options
Print post
Permalink
This process used to work for me, but no longer does. I don't know
what's wrong with it. I don't believe I changed any code, but perhaps
I'm missing something.

It works perfectly in the development environment, but never makes it
past the "qtinitialize" line as a standalone.

I start with a fresh stack (under XP). I use the following to set a
custom property, EQT:

    set the EQT of this stack to url "binfile:enhancedQT.dll"

I then use this stack script:

----------------------------------------------
on openstack
  put "here" into url "file:checkit.txt"
  qtInitialize
  put "done" into url "file:checkit.txt"
end openstack

on preopenstack
  loadexternals
end preopenstack

ON loadExternals
  put the short name of this stack into tStack
  put the eqt of this stack into pExternals
  IF there is not a stack "myExternals" THEN
    reset templatestack
    set destroywindow of templatestack to true
    set destroystack of templatestack to true
    set visible of templatestack to false
    set externals of templatestack to pExternals
    create stack "myExternals"
    reset templatestack
  END IF
  go stack "myExternals"
  start using stack "myExternals"
  set the defaultstack to tStack
END loadExternals
----------------------------------------------

It simply dies at QTInitialize. Any thoughts?

Thanks.
Richard Miller
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Jack Rarick

RE: "set the externals" routine for enchanced QT no longer working

Reply Threaded More More options
Print post
Permalink
Richard!

I ran into this problem a lot a year ago and used EXACTLY what you're typing there. The only thing that seemed to help was after creating the standalone I would restart my computer. For some reason that cleaned up a lot of the mess. I am away from the rev code I used but I will check tonight when I get back to the office.

Jack Rarick
Braintree Athletic Systems

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Richard Miller
Sent: Thursday, November 05, 2009 11:06 AM
To: How to use Revolution
Subject: "set the externals" routine for enchanced QT no longer working

This process used to work for me, but no longer does. I don't know
what's wrong with it. I don't believe I changed any code, but perhaps
I'm missing something.

It works perfectly in the development environment, but never makes it
past the "qtinitialize" line as a standalone.

I start with a fresh stack (under XP). I use the following to set a
custom property, EQT:

    set the EQT of this stack to url "binfile:enhancedQT.dll"

I then use this stack script:

----------------------------------------------
on openstack
  put "here" into url "file:checkit.txt"
  qtInitialize
  put "done" into url "file:checkit.txt"
end openstack

on preopenstack
  loadexternals
end preopenstack

ON loadExternals
  put the short name of this stack into tStack
  put the eqt of this stack into pExternals
  IF there is not a stack "myExternals" THEN
    reset templatestack
    set destroywindow of templatestack to true
    set destroystack of templatestack to true
    set visible of templatestack to false
    set externals of templatestack to pExternals
    create stack "myExternals"
    reset templatestack
  END IF
  go stack "myExternals"
  start using stack "myExternals"
  set the defaultstack to tStack
END loadExternals
----------------------------------------------

It simply dies at QTInitialize. Any thoughts?

Thanks.
Richard Miller
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Trevor DeVore

Re: "set the externals" routine for enchanced QT no longer working

Reply Threaded More More options
Print post
Permalink
In reply to this post by Richard Miller-5
On Nov 5, 2009, at 11:06 AM, Richard Miller wrote:

> I start with a fresh stack (under XP). I use the following to set a  
> custom property, EQT:
>
>   set the EQT of this stack to url "binfile:enhancedQT.dll"

You are loading binary data into a custom property here.

> I then use this stack script:
>
> ----------------------------------------------
> on openstack
> ...
> put the eqt of this stack into pExternals

Then you are putting this binary data into a variable.

> IF there is not a stack "myExternals" THEN
>   reset templatestack
>   set destroywindow of templatestack to true
>   set destroystack of templatestack to true
>   set visible of templatestack to false
>   set externals of templatestack to pExternals

Then you are setting a property of a stack that expects a path to a  
file to the binary data. Are you sure this worked before?

--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Releasable Revolution Resources for Developers: http://revolution.bluemangolearning.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Richard Miller-5

Re: "set the externals" routine for enchanced QT no longer working

Reply Threaded More More options
Print post
Permalink
Used to work fine. But that's not important. What do you suggest I do to
get it working now? I'd prefer to have one standalone file. That was the
reason for putting the binary data into the custom property to begin
with... to avoid a separate DLL file to download.

Sounds like you are saying the below routine would work fine if I simply
included the DLL as a separate file and avoided the custom
property/variable approach.

Thanks.
Richard


Trevor DeVore wrote:

> On Nov 5, 2009, at 11:06 AM, Richard Miller wrote:
>
>> I start with a fresh stack (under XP). I use the following to set a
>> custom property, EQT:
>>
>>   set the EQT of this stack to url "binfile:enhancedQT.dll"
>
> You are loading binary data into a custom property here.
>
>> I then use this stack script:
>>
>> ----------------------------------------------
>> on openstack
>> ...
>> put the eqt of this stack into pExternals
>
> Then you are putting this binary data into a variable.
>
>> IF there is not a stack "myExternals" THEN
>>   reset templatestack
>>   set destroywindow of templatestack to true
>>   set destroystack of templatestack to true
>>   set visible of templatestack to false
>>   set externals of templatestack to pExternals
>
> Then you are setting a property of a stack that expects a path to a
> file to the binary data. Are you sure this worked before?
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Trevor DeVore

Re: "set the externals" routine for enchanced QT no longer working

Reply Threaded More More options
Print post
Permalink
On Nov 5, 2009, at 11:43 AM, Richard Miller wrote:

> Used to work fine. But that's not important. What do you suggest I  
> do to get it working now? I'd prefer to have one standalone file.  
> That was the reason for putting the binary data into the custom  
> property to begin with... to avoid a separate DLL file to download.

I'm not sure how it could of worked unless the engine has an  
undocumented feature whereby it can load the binary data of an  
external. If it does then that would be very cool. I've never heard of  
that before though.

> Sounds like you are saying the below routine would work fine if I  
> simply included the DLL as a separate file and avoided the custom  
> property/variable approach.

You have to point 'the externals' property to a file on disk. You  
could try spitting out your binary data into a file in the temp  
directory and then assigning the externals property of the stack to  
that temp file.

--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Releasable Revolution Resources for Developers: http://revolution.bluemangolearning.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Richard Miller-5

Re: "set the externals" routine for enhanced QT no longer working

Reply Threaded More More options
Print post
Permalink
Thanks.



Trevor DeVore wrote:

> On Nov 5, 2009, at 11:43 AM, Richard Miller wrote:
>
>> Used to work fine. But that's not important. What do you suggest I do
>> to get it working now? I'd prefer to have one standalone file. That
>> was the reason for putting the binary data into the custom property
>> to begin with... to avoid a separate DLL file to download.
>
> I'm not sure how it could of worked unless the engine has an
> undocumented feature whereby it can load the binary data of an
> external. If it does then that would be very cool. I've never heard of
> that before though.
>
>> Sounds like you are saying the below routine would work fine if I
>> simply included the DLL as a separate file and avoided the custom
>> property/variable approach.
>
> You have to point 'the externals' property to a file on disk. You
> could try spitting out your binary data into a file in the temp
> directory and then assigning the externals property of the stack to
> that temp file.
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Michael Kann

Re: search for regular expression in text and put the results into an array

Reply Threaded More More options
Print post
Permalink
In reply to this post by Michael Kann
The first script that got away didn't count the frequency correctly. This one I hope does so. I also noticed that the other one referred to teams in the scripts and restaurants in the data. I guess I got hungry halfway through the project. I also changed fld "a" to fld "input" and fld "b" to fld "output"

I took out the part where it lists the restaurants as they appear in the raw data. Now you only get the frequency, which was the original intent.

Sorry if I caused too much trouble with the last script. I'll be more careful in the future.


on mouseUp

put fld "input" into v
put empty into fld "output"

put "<res>" into  aTag
put "</res>" into bTag

replace return with "*" in v
replace aTag with return in v

replace bTag with "@" in v
filter v with "*@*"

set the itemDelimiter to "@"

repeat for each line curLine in v
put item 1 of curLine into curRestaurant
add 1 to frequencyRes[curRestaurant]
end repeat

put "restaurants and frequency" & cr into h
combine frequencyRes with cr and space
sort frequencyRes numeric descending by last word of each
put h & cr & frequencyRes & cr after fld "output"

end mouseUp


     
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution