Using lists and fileio
I hope I haven't missed the solution to this in searching, I
apologise if I have.
I'm saving some basic user details from my projector (DMX
2004, PC) using fileio and the saving bit works fine. What I was
aiming to do was construct a list and then put this out to a file,
so.
pDetails = ["Forename", "Surname"] -- and so on
userdets = new (xtra "fileio")
setFilterMask (userdets,"Text Files, *.txt")
filename = userdets.displaySave("Save your details to...",
"userdets.txt")
createfile (userdets, filename)
openfile (userdets, filename, 2)
writeString (userdets, string(pDetails))
userdets.closeFile()
This works fine - examining the saved text file it contains
["Forename", "Surname"] (obviously this data is actually provided
from text input). However, when I try and read the file in,
Director treats it as a string and encloses the whole thing in
quotes so in
pDetails = userdets.readFile()
pDetails comes in as "["Forename", "Surname"]" which I then
can't read as a list.
So... is there either a readfile method that specifies the
data is a list, or is there a better way to store this data full
stop? I'm able to get it working by simply storing a string using
delimiters (i.e. the saved file contains just Forename, Surname and
is brought in as "Forename, Surname") but I'd really like to use a
list so I can make it a property list in the final version.
Am I making any sense? :)
Jon
The best solution is to store each item in your list as a
separate line
in the text file. This will get you around the list in a
string dilemma.
Try this:
pDetails = ["Forename", "Surname"] -- and so on
totalItems = pDetails.count
repeat with i = 1 to totalItems
myString = myString & pDetails
& RETURN
end repeat
delete myString.line[myString.line.count]
userdets = new (xtra "fileio")
setFilterMask (userdets,"Text Files, *.txt")
filename = userdets.displaySave("Save your details to...",
"userdets.txt")
createfile (userdets, filename)
openfile (userdets, filename, 2)
writeString (userdets, myString)
userdets.closeFile()
Then to get your data back, do something like this:
pDetails = userdets.readFile()
tempList = []
totalLines = pDetails.line.count
repeat with n = 1 to totalLines
if value(pDetails.line[n]) = VOID then
totalLines.add(pDetails.line[n])
else
totalLines.add(value(pDetails.line[n]))
end if
end repeat
pDetails = tempList
Rob
Rob Dillon
Adobe Community Expert
http://www.ddg-designs.com
412-243-9119
http://www.macromedia.com/software/trial/
Similar Messages
-
Getting StorageManagementInformation using Lists and Libraries
Good morning,
I am using SPSite.StorageManagementInformation to get the size used for my sites. The idea I have is calling this method twice with an accurate number on the limits due to the bad performance this method have (the first call will be run
with SPSite.StorageManagementInformationType.DocumentLibrary and the second one with SPSite.StorageManagementInformationType.DocumentLibrarySPSite.StorageManagementInformationType.List).
Now my question is: what is a list and what is a library? I have run these two methods with a high value for testing and, for example, for Document Libraries I get the next template Ids: 101, 113,114,116,121,122,123 and 851.
I would like to query every list in my SPSite and increase the counter depending on if it is a List or a Library (screenshots attached).
Thanks in advanceHi,
If you want to know how to check if ListTemplateType is list or library, the following code snippet for your reference:
using (SPSite site = new SPSite("http://sp2013sps:8080"))
SPWeb web = site.OpenWeb();
int libsCount = 0;
int listsCount = 0;
foreach (SPList list in web.Lists)
if (list.BaseType == SPBaseType.DocumentLibrary)
libsCount++;
else
listsCount++;
Console.WriteLine(libsCount+"|"+listsCount);
Console.ReadKey();
Best Regards,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
Tab distance in Pages when using List and Tab
Has anyone else noticed that sometime in the last update or 2 that the distance the TAB shortcut, or the --> arrow (under Inspector>List) moves the cursor is double the distance it used to be?
The reason I noticed is because I have a few reports on there, and was working on them today, but I can't match the tab distance anymore. Is there a way to adjust how far --> moves the cursor, _WITHOUT setting tab_ stops on the ruler? I want to use --> from the List menu, not the TAB button.
I noticed that if you select Bullet from the list menu the tab distance is the same as it used to be for ALL the List options, but it's only when you select None that it is double. (it used to be the same as the Bullet tab distance).
Does anyone know how to adjust this, or work around it? Using Tab doesn't provide the formatting I need, so _setting tab stops doesn't help_. I don't want to create bullets and then re-color them white either!Realized my flaw... Those documents originated on the computer (which I forgot) - that is why I couldn't get the tabs to match. My mistake!
-
I have a real world problem where I get a list of retail store location and get the distance from group of starting locations and find the 10 closest location for each starting locations. I get returned from getdata a list of stores loop through each store and calculate the distance and put them in a treeset for sorting. Problem is when the second set of data is added to the treeset the original set is replace with a duplicate set of the second set. a very simple test case for this is follows:
package treeset;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.TreeSet;
import java.io.Serializable;
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Class TreeSetExample
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
* The TreeSetExample demonstreates a odity in the sorting of list using a treeset
* @version 1.0, 04/06/2011
* @author Douglas Nelson
* @author copyright Oracle 2011
* @author Unauthorized use, duplication or modification is strictly prohibited.
public class TreeSetExample extends Object {
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// start constructor
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
* Constructs a TreeSetExample object
public TreeSetExample() {
} // end constructor
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// start getData
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
* getDatea
public List<SimpleVO> getData() {
List<SimpleVO> returnList = new LinkedList<SimpleVO>();
SimpleVO simpleVO = null;
for (int i = 0;i < 5;i++) {
returnList.add(new SimpleVO());
} // end for
return(returnList);
} // end getData
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// start runTest
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
* runTest - Test the insert sorting of a tree set with a list of data
* @param loopCount number of time to load data into the saveset
public void runTest(int loopCount) {
List<SimpleVO> simpleList = getData();
SimpleVO simpleVO = null;
TreeSet<SimpleVO> saveSet = new TreeSet<SimpleVO>(new simpleComparator());
SimpleVO tempSimpleVO = null;
Iterator<SimpleVO> iterator = null;
Iterator<SimpleVO> printIterator = null;
int id = 0;
for (int i = 0; i < loopCount;i++) {
iterator = simpleList.iterator();
// for each of the user's zip codes find the distance to the RSL
while (iterator.hasNext()) {
simpleVO = iterator.next();
id ++;
simpleVO.setName("" + id);
saveSet.add(simpleVO);
} // end while
// print saveset at the end of each load
System.out.println("list count after loop [" + (i + 1) + "] number of elements = [" + saveSet.size() + "] contents:");
printIterator = saveSet.iterator();
while(printIterator.hasNext()) {
tempSimpleVO = printIterator.next();
System.out.println(" save simpleVO name = [" + tempSimpleVO.getName() + "]");
} // end while
} // end For
} // end runTest
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// start main
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
* IbotMailParser main thread
* @param arg standard main input string array.
public static void main(String[] arg) {
System.out.println("Main - Started");
try {
System.out.println("*************** starting test 1 *********************");
TreeSetExample treeSetExample = new TreeSetExample();
treeSetExample.runTest(1);
System.out.println("\n");
System.out.println("\n");
System.out.println("*************** starting test 2 *********************");
treeSetExample.runTest(2);
} // end try
catch (Exception any) {
System.out.println("Exception [" + any.getMessage() + "]");
} // end catch
System.out.println("Main - we gone bye-bye...!");
} // end main
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Class SimpleVO
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
* The SimpleVO is a value object pattern used for this example
* @version 1.0, 04/06/2011
* @author Douglas Nelson
* @author copyright Oracle 2011
* @author Unauthorized use, duplication or modification is strictly prohibited.
public class SimpleVO extends Object {
* Default user name for Oracle connection.
private String name = "";
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// start getName
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
* Returns the name value associated with this attribute
* @return String - the Name parameter
public String getName() {
return(name);
} // end getName
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// start setName
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
* Sets the name value for this attribute
* @param newName the Name to be set
public void setName(String newName) {
if (newName != null) {
name = newName.trim();
} // end if
} // end setName
} // end SimpleVO
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Class simpleComparator
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
* The SimpleComparator is a comparator object used for sorting simple value objects
* @version 1.0, 04/06/2011
* @author Douglas Nelson
* @author copyright Oracle 2011
* @author Unauthorized use, duplication or modification is strictly prohibited.
public class simpleComparator implements Comparator<SimpleVO>, Serializable {
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// start getName
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
* Returns the name value associated with this attribute
* @return String - the Name parameter
public int compare(SimpleVO simpleVO_1, SimpleVO simpleVO_2) {
return(1);
} // end compare
} // end SimpleComparator
} // end class TreeSetExample
output :
c:\treeset>java treeset.TreeSetExample
Main - Started
*************** starting test 1 *********************
list count after loop [1] number of elements = [5] contents:
save simpleVO name = [1]
save simpleVO name = [2]
save simpleVO name = [3]
save simpleVO name = [4]
save simpleVO name = [5]
*************** starting test 2 *********************
list count after loop [1] number of elements = [5] contents:
save simpleVO name = [1]
save simpleVO name = [2]
save simpleVO name = [3]
save simpleVO name = [4]
save simpleVO name = [5]
list count after loop [2] number of elements = [10] contents:
save simpleVO name = [6]
save simpleVO name = [7]
save simpleVO name = [8]
save simpleVO name = [9]
save simpleVO name = [10]
save simpleVO name = [6]
save simpleVO name = [7]
save simpleVO name = [8]
save simpleVO name = [9]
save simpleVO name = [10]
Main - we gone bye-bye...!
Edited by: EJP on 7/04/2011 10:44: added code tags. Please use them.user12607386 wrote:
I have a real world problem where I get a list of retail store location and get the distance from group of starting locations and find the 10 closest location for each starting locations. I get returned from getdata a list of stores loop through each store and calculate the distance and put them in a treeset for sorting. Problem is when the second set of data is added to the treeset the original set is replace with a duplicate set of the second set. a very simple test case for this is follows:Well, first off, when you post code, please put it in '' tags; but the basic problem is your[code]simpleVO.setName("" + id);[/code]line. A name should normally be *final*, so you shouldn't be able to set it at all.
When you add the second set of 5 to your Set, you're simply changing the name of the first 5 you just added, but since your Comparator doesn't actually do anything useful, it allows the second 5 to be added, which, of course, then show up as duplicates.
My advice: +THINK+ about what you want to do; don't just sit down and code. If need be, get out a pencil and paper and write out in English the steps you need.
Winston -
Using the tab key in a list and keeping a table format when copying and pas
when I transfer a table from a microsoft word document or PDF file to the pages document, it does not keep the table and only the data inside the table. how do I keep the table?
Also, how do I keep the numbers from indenting when I do a list. for example, if I need to indent part of the sentence for writing specifications of something, I want to use the tab key to move away from the first part of the sentence, but it moves everything and not just my marker.Not if it decides the list is a list, it can't.
The app never "decide that a list is alist". It does what you ask it to do.
Of course, if you refuse to disable the preference which automatically treats a paragraph as a new list entry I can't help you.
If the datas are stored as a list, the bullets are not part of the datas themselves so they will not be copied.
As I already responded the "Copy" tool doesn't copy attributes.
We have to choose:
we are using lists and the bullets can't be copied
or
we are using text arranged in columns and, if we put bullets, these bullets may be copied.
It's not me which wrote:
+In Textedit, it's very easy:+
+Tab, Bullet, First Column, Tab (or Tab x2 to get everything aligned), Second Column, etc.+
To do the same thing in Pages
Bullet, Tab, First Column, Tab (or Tab x2 to get everything aligned), Second Column, etc.
It's what was displayed in my screenshot and really I don't see what is more complicated. -
How to use List within javaFX(*.fx) script?
How to use java.util.List within javaFX(*.fx) script?
The following is my code in Java
PDBFileReader pdbreader = new PDBFileReader();
pdbreader.setPath("/Path/To/PDBFiles/");
pdbreader.setParseSecStruc(true);// parse the secondary structure information from PDB file
pdbreader.setAlignSeqRes(true); // align SEQRES and ATOM records
pdbreader.setAutoFetch(true); // fetch PDB files from web if they can't be found locally
try{
Structure struc = pdbreader.getStructureById(code);
System.out.println("The SEQRES and ATOM information is available via the chains:");
int modelnr = 0 ; // also is 0 if structure is an XRAY structure.
List<Chain> chains = struc.getChains(modelnr);
for (Chain cha:chains){
List<Group> agr = cha.getAtomGroups("amino");
List<Group> hgr = cha.getAtomGroups("hetatm");
List<Group> ngr = cha.getAtomGroups("nucleotide");
System.out.print("chain: >"+cha.getName()+"<");
System.out.print(" length SEQRES: " +cha.getLengthSeqRes());
System.out.print(" length ATOM: " +cha.getAtomLength());
System.out.print(" aminos: " +agr.size());
System.out.print(" hetatms: "+hgr.size());
System.out.println(" nucleotides: "+ngr.size());
} catch (Exception e) {
e.printStackTrace();
}The following is my code in JavaFX(getting errors)
var loadbtn:SwingButton = SwingButton{
text:"Load"
action: function():Void{
var pdbreader = new PDBFileReader();
var structure = null;
try{
structure = pdbreader.getStructure(filepath.text);
List<Chain> chains = structure.getChains(0);
foreach (Chain cha in chains){
List < Group > agr = cha.getAtomGroups("amino");
List < Group > hgr = cha.getAtomGroups("hetatm");
List < Group > ngr = cha.getAtomGroups("nucleotide");
} catch (e:IOException) {
e.printStackTrace();
};I'm using Netbeans 6.5 with JavaFX
(PDBFileReader, Chain, Structure etc are classes from my own package, already added to the library folder under the project directory)
Simply put, How to use List and Foreach in JavaFX?We can not use Java Generics syntax in JavaFX. But we can use Java Collection classes using the keyword 'as' for type-casting.
e.g.
import java.util.LinkedList;
import java.util.List;
import javafx.scene.shape.Rectangle;
var outerlist : List = new LinkedList();
var innerlist : List = new LinkedList();
innerlist.add(Rectangle{
width: 10 height:10});
innerlist.add(Rectangle{
width: 20 height:20});
outerlist.add(innerlist);
for (inner in outerlist) {
var list : List = inner as List;
for (element in list) {
var rect : Rectangle = element as Rectangle;
println("(width, height)=({rect.width}, {rect.height})");
} -
What is the transaction code for where used list
hi,
what is the transaction code for where used list and
how to retrieve the previous delivery quantity and quantity delivered for a particular material with reference to both material document number and material number.hi,
there is no transaction code for where-used-list..
its one of the buttons in application tool bar which if you click will tell you where,in which program or tables etc this object is used.
to retrieve the previous delivery quantity and quantity delivered for a particular material with reference to both material document number and material number,
use tables <b>likp lips and mara</b> and use material number and document number in where condtion.
regards,
pankaj singh
<b>**** please mark all helpful answers</b> -
Hi eveyone,
I need to find all the programs that are using a particular field...lets say zname...the only way that I knw is to go se11 and gointo the table where that field is defined...click on the field and do the where used list and then it will give me the list of all the programs where that field is being used...but my question is by doing so will I be able to get the list of all the programs or will I be missing any...because someone told me you might miss on if that field is used in the structure also and then it will not popup the list of the programs where that structure is used...so can you please tell me how can I take care of this.
Thanks,
RajeevWhere used list of Programs will not provide you with the list of programs where the Data element is not used for type/like declaration.
Instead you should scan. Remeber giving the program name as Z* if you wish to search in z programs. -
When I tried to open my Mail app on my IPhone this morning, it opened a list of choices - iCloud, E Exchange, Google, Yahoo, Aol, Outlook. I use Hotmail and it usually opens to my Inbox. Why did it do this and do I choose Outlook and is it safe to sign in?
It sounds like instead of opening your Mail App, you actually opened your Settings App, and were somehow in the 'Add Account' section of Mail, Contacts & Calendars.
Close the apps, and then reopen just the Mail App. -
I'm wanting to use the "Actions" in Photoshop Elements 11. But when I get the actions box up, it is only showing a small list of effects to use. And no side bar. So I can't go any further. When I click on the little arrow at top and click on "load actions", I am only getting a box with empty space saying "No items match your search". The folder at the top does say "Actions". How do I get more effects? The tutorials that I've checked into all show a long list of effects in their box. Can anyone help?
To use the existing actions, try the following:
1. Open one of the Action Sets, in this example Special Effects is the Action Set, by pressing the small arrow beside the set name.
2. Then click on the name of the Action, in this example Faded Ink is the Action name.
3. Then press the Play button to run the action. -
How do I change the Apple id that is listed as my home share on my apple tv? I bought a used one and it has the previous owners apple id loaded in the home share.
Welcome to the Apple community.
Settings > computers. -
One of my calendars (one of several) has vanished. It is not simply unchecked, but is totally gone. I have a MacBook Pro, iPad mini, iPhone 5c - this calendar is gone from all devices. I do have and use iCloud and calendars is turned on. I have turned off calendars and back on as well as turned off iCloud and then the device itself. Nothing has worked and this has all my own personal appointments on it. Any ideas of how to restore this one calendar and make it available in my list of the other calendars again?
This is designed to be a user discussion area. To provide feedback directly to Apple you can go to http://www.apple.com/feedback/
There are a few applications out now that may be able to help you out. 1Password and LastPass are both password vault or lockers. They allow you to save passwords for applications and websites. That way you have a single password you use to keep the vault/locker secure and then all of your other passwords are stored for you so you don't have to write them down or try to remember them all.
https://agilebits.com/onepassword
https://lastpass.com/index.php -
How to edit data using a LOV list AND textfield for one Field
I am trying to edit the templated edit from HTMLDB template when I create a new table. I implemented most of the fields with LOV list like yes/no, joe/bob/john etc. But some fields as many probably have seen have a LOV called "Other" where a person types a different value than the ones available. Can someone tell me how I can accomplish that? Do I need to insert "Other" into LOV and have it be set as the value in the textfield? I am not sure how i can create both LOV list and textfield per category/field i.e. Name.
ThanksAgain, I urge you to use HTML DB nomenclature to describe what you've done. For example: "I ran the Form on a Table wizard to create a form" Rather than using the word "template" for everything you describe. "Template" has a specific meaning in HTML DB and it is not what you are referring to.
You really should invest the time required to accurately phrase your problem. Just like answering questions on this forum requires time, so does formulating your question. It is time well spent and it is effort on your part that the experts on this forum deserve. If you don't put in this effort and instead just post a stream of consciousness, that means the readers of this forum will gloss over your question and ignore it. As a result, you have to ask the question again...and again.
Having said that, if I understand your question correctly, you should use a popup LOV item. This will allow the user to select from a list but will also allow typing of a non existent option into a text field.
Sergio -
The Control A key is not working. I cannot multi-select my songs. I'm not sure if it is the problem with iTunes 10.6.1.7 or my PC settings encounter issues. Also, i cannot find Album Artwork online using iTunes and i cannot select any view form but List.
The Control A key is not working. I cannot multi-select my songs. I'm not sure if it is the problem with iTunes 10.6.1.7 or my PC settings encounter issues. Also, i cannot find Album Artwork online using iTunes and i cannot select any view form but List.
-
I have used this before in earlier versions of DW and it worked fin. I tried tonight with CC 2014.1.1 in either design view or in codeview with the same results. I would select the text from the starting <p> tag to the ending </p> tag, and then in the menu choose Format - List - Definition List and only get the <dl> tags. Anyone else experience this?
Thanks!That's how it works in CS6, too. And it is not just for definition lists. That is the expected outcome no matter which list type you use. DW doesn't know where the DTs and DDs begin and end because you've highlighted an entire paragraph and asked DW to format it as a DL.
I typically code my own Definition Lists. It's faster.
Nancy O.
Maybe you are looking for
-
Iphone 4s on 5.0.1 Messaging Issue
After I the 5.0.1 release, I have noticed a major issue in Messaging. If I selected "Messages", it opens to the latest text message I was viewing. But the problem is, there is no title block at the top saying who I am texting with... and because ther
-
Issue on physical standby database
Hi I've a problem on standby database. I recently added a datafile on primary database, then I scp'ed the data file to physical standby database.On physical standby database I tried performing recovery. I get following message in my alert log WARNING
-
MM Open Purchase Order by Cost Center
Does anyone knows of a report that can give me Open Purchase orders Orders by Cost Centers? Thanks for your help
-
I know this may sound like a strange request, but if there is anyone here with a Nokia 7373 phone, i was hoping you might be able to help me. I have one of these, but i have managed to crush my display so i can't see anything on it. So if there is so
-
Can not power down my HTC Droid Incredible as the phone options menu will not display.
Press down power switch at top of device for up to a minute and nothing happens. Options menu no longer appears. Had trouble with the device about 2 weeks ago where nothing would work and I was getting force close messages. Found a solution on this