Barre défilement
Bonjour,
J'ai un tableau de plus de 50 colonnes. J'aimerais accrocher à ce tableau une barre de défilement, mais je ne trouve pas comment faire.
Quelqu'un pourrait-il m'aider peut-être en m'envoyant un exemple ? J'ai la version 8.5 de LabVIEW.
Cordialement
Bonjour,
La scrollbar est native sur les tableaux, mais pas visible par defaut. Il suffit de la sélectionner dans les éléments visibles (clic droit: Visible items)
Cordialement,
Simon D.
CLA | Certified LabVIEW Architect
CTA | Certified TestStand Architect
Similar Messages
-
Barre de défilement sur commande désactivée
Boujour,
Voici mon souscis:
Je voudrais laisser la barre de défilement verticale activée et disponible sur une commande de liste déroulante lorsque celle-ci est désactivé.
En effet si la commande est désactivée et que les données dans la liste dépassent le nombre de lignes affichables, il n'est pas possible de faire glisser la barre de défilement verticale.
L'utilisateur doit avoir en fonction d'un mode d'édition préalable :
- soit de pouvoir selectionner un ou plusieurs éléments de la liste -> donc ça doit-être une commande (pas possible avec un indicateur).
- soit de ne pas avoir accès la sélection des éléménts (qui se fera ailleurs) mais pouvoir visualiser toute la liste dont le nombre peut dépasser la zone d'affichage.
Merci pour vos contributions.
NicolasBonjour,
Ce n'est pas possible.
Une solution est de rendre invisible la barre de défilement et d'en créer une avec un controle glissière par exemple pour reproduire le comportement attendu.
Cordialement,
Da Helmut -
Barre de défilement dans cluster
Bonjour,
Je suis à la recherche d'indications pour utiliser une barre de défilement dans un cluster.
J'ai déja regardé dans l'aide labView ou un VI est expliqué mais je ne comprends pas le fonctionnement.
Je m'explique: J'ai un cluster ou à l'interieur j'ai une multitude de tableau 1D.
J'aimerai me déplacer verticalement dans les tableaux avec une barre de défilement verticale.
Si quelqu'un sait comment faire, je lui serait trés reconnaissant de m'expliquer la manip.
Merci
Thomas Muller
En pièce jointe un screen du cluster.
Attachments:
screen.JPG 35 KBBonjour,
Voici un exemple labview pour utiliser la barre de défilement dans un cluster.
Cordialement
VéroniqueD
NI France
Attachments:
Cluster with Scrollbar.vi 26 KB -
depuis que j'ai installe mountain,je n'ai plus de barres de défilement et la flèche page précédente ne marche plus
merci de me renseigner.Cordialement .MPbonjour
est ce dans Safari? Vous devrez peut-être d'ajuster votre résolution d'écran -
buongiorno, vorrei eliminare dallo secondo monitor (proiettore) la barra degli strumenti in alto (finder, file composizione,vista ecc..) che è comparsa con l'istallazione del nuovo aggiornamento mavericks. E' possibile?
-
En que barra de herramientas esta el Write Characters From File
buenos dias necesito saber en que grupo de herramientas esta la función Write Characters From File
Gracias por la ayudajzavala_espoch escribió:
buenos días necesito saber en que grupo de herramientas esta la función Write Characters From File
¿ "Write Characters to File" o "Write Characters From File"?, Si esta haciendo referencia a la primera este es un VI que no aparece desde la Versión 8.2 de LabVIEW ya que hacia la misma función que el "Write to Text File" si aun desea utilizarlo este VI se encuentra en la librería que se adjunta, si por el contrario es "Write Characters From File" no he observado esa funcion, a no ser que sea algun VI personalizado.
Jonathan Cruz
CHALLENGER
K U D O S __ B I E N V E N I D O S
Attachments:
file.llb 847 KB -
How to read a text file into a String?
and also write a text file from a String. I searched the forum and found this folowing code:
// Read and append... by Example
try{
String fileName = "text.txt"; // Filename
// Make the inputfile object
FileInputStream fi = new FileInputStream(fileName);
byte inData[] = new byte[fi.available()];
fi.read(inData); // Read
fi.close(); // Close
String text = new String(inData); // Make a textstring...
// Now, do whatever you want with the data... and append...
String textToAppend = "kjkjhjhKJ";
byte outData[] = textToAppend.getBytes();
// Make the outputfile (whith the 'append' boolean set to true
FileOutputStream fo = new FileOutputStream(fileName,true);
fo.write(outData);
fo.close();
}catch(Exception oops){}but it returns funny characters to the String from the text file and vice versa in writting the text file. Can anybody please help? Thank you.
kindoSee here for info on encodings:
http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html
Some common US encodings and common uses:
ASCII (DOS)
Cp1252 (Windows 9x)
UTF8 (XML)
import java.io.*;
public class TextFile extends File
private static String DEFAULT_ENCODING = "ASCII";
private File file;
private String encoding;
public TextFile(File file, String encoding)
super(file.getPath());
this.file = file;
this.encoding = encoding;
public TextFile(File file)
this(file, DEFAULT_ENCODING);
public String load() throws Exception
FileInputStream fis = new FileInputStream(file);
byte[] barr = new byte[fis.available()];
fis.read(barr);
fis.close();
return new String(barr, encoding);
public void save(String str) throws Exception
FileOutputStream fos = new FileOutputStream(file);
fos.write(str.getBytes(encoding));
fos.close();
} -
In Numbers 08 is it possible to add a link to a file on the local disc within a cell?
In Numbers 08 is it possible to add a link to a file on the local disc within a cell?
As it's a feature asked several times, maybe it will be available in the next version.
I don't know features available in Excel.
Sometimes ago I posted an AppleScript which may perhaps fit your needs.
If you insert in a table pathnames of files stored in your HD, select the cell, trigger the script, open the file.
Here is an updated version :
--[SCRIPT open_a_file]
Enregistrer le script en tant que Script : open_a_file.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Library:Scripts:Applications:Numb ers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner la cellule contenant le chemin d'accès
Aller au menu Scripts , choisir Numbers puis choisir “open_a_file”
ouvre le fichier.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
--=====
Save the script as a Script: open_a_file.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select the cell containing the pathname
Go to the Scripts Menu, choose Numbers, then choose “open_a_file”
open the file
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
Save this script as a … Script in the "Folder Actions Scripts" folder
<startupVolume>:Library:Scripts:Folder Action Scripts:
--=====
Yvan KOENIG (VALLAURIS, France)
2010/02/02
2011/04/28 - replaced the getSelParams handler by the get_SelParams one
--=====
on run
set {dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
set maybe to value of cell rowNum1 of column colNum1
end tell -- Numbers
tell application "Finder" to open maybe
end run
--=====
set { dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
on get_SelParams()
local d_Name, s_Name, t_Name, row_Num1, col_Num1, row_Num2, col_Num2
tell application "Numbers" to tell document 1
set d_Name to its name
set s_Name to ""
repeat with i from 1 to the count of sheets
tell sheet i to set maybe to the count of (tables whose selection range is not missing value)
if maybe is not 0 then
set s_Name to name of sheet i
exit repeat
end if -- maybe is not 0
end repeat
if s_Name is "" then
if my parleAnglais() then
error "No sheet has a selected table embedding at least one selected cell !"
else
error "Aucune feuille ne contient une table ayant au moins une cellule sélectionnée !"
end if
end if
tell sheet s_Name to tell (first table where selection range is not missing value)
tell selection range
set {top_left, bottom_right} to {name of first cell, name of last cell}
end tell
set t_Name to its name
tell cell top_left to set {row_Num1, col_Num1} to {address of its row, address of its column}
if top_left is bottom_right then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
tell cell bottom_right to set {row_Num2, col_Num2} to {address of its row, address of its column}
end if
end tell -- sheet…
return {d_Name, s_Name, t_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end tell -- Numbers
end get_SelParams
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
Oops, I forgot that you are asking about Numbers '08 which hasn't AppleScript support.
Yvan KOENIG (VALLAURIS, France) jeudi 28 avril 2011 16:26:39
Please :
Search for questions similar to your own before submitting them to the community -
Tem um componente no Flash que aplica a barra de rolagem, mas queria saber se tem uma maneira de personalizála. o componente scrollbar, apenas muda a coloração da barra, quero saber como criar uma barra de rolagem personalizada.
It has a component in the Flash that applies the bar of clod roller, but wanted to know if it has a way of personalizála. the component to scrollbar, only dumb the coloration of the bar, I want to know as to create a bar of personalized clod roller.
Exemplo :http://www.djfilipemonteiro.com.br/?gclid=CNa4lsLes6ECFQUf7god-1x8_wI am modifying the correct httpd.conf file on the server, it just doesn't seem to work. - If I put the rewrite rules in the <Directory /> the rewrite works but it adds /Library/WebServer/Documents to the URL.
I also tried putting the rewrite rules in <IfModule mod_rewrite.c> but that did not work either.
mod_rewrite is enabled and running on the server.
I will post the rewrite rules again in the code brackets. Sorry for the long post. - If some one can try them out on their Leopard Server to see if they can get them to work, it would be much appreciated. Again, these work on my Leopard Client but I can't get them to work on Server.
-- The httpd.conf file posted above is just the default conf file found in /private/etc/apache2/
<code>
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^(.+)/$ http://%{HTTP_HOST}$1 [R=301, L]
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.php(.*)\ HTTP
RewriteRule (.+)\.php(.*)$ $1$2 [R, L]]
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.asp(.*)\ HTTP
RewriteRule (.+)\.asp(.*)$ $1$2 [R, L]]
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.aspx(.*)\ HTTP
RewriteRule (.+)\.aspx(.*)$ $1$2 [R, L]]
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.htm.(.)\ HTTP
RewriteRule (.+)\.htm.(.)$ $1$2 [R, L]]
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.cfm(.*)\ HTTP
RewriteRule (.+)\.cfm(.*)$ $1$2 [R, L]]
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.bak(.*)\ HTTP
RewriteRule (.+)\.bak(.*)$ $1$2 [R, L]]
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.inc(.*)\ HTTP
RewriteRule (.+)\.inc(.*)$ $1$2 [R, L]]
RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\..(.)\ HTTP
RewriteRule (.+)\..(.)$ $1$2 [R, L]]
<code> -
How I can read an xml file with SAX or DOM into a war file?. I have WLS 6.1 SP4
with WLI2.1 SP2.
I can read a xml file, but when I create a war file, the aplication does not find
the xml file. When it tries to find it, it looks on the path but not on the war
which contains the xml file needed.
This is the instruction given:
String uri = "Menu.xml";
DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse( uri );
And the error message displayed is:
File "file:///c:/bea/wli21/Memu.xml" not found
Coments please!!
EdyThe error is calss org.xml.sa.SAXParseException: File "localhost:7001/Menu.xml"
not found
I change localhost by the correct IP.
Tks.
Edy
"Karthik V" <[email protected]> wrote:
What error message are you getting now?
Can you produce the trace?
Try using File or InputStream while Parsing.
That will help you to narrow down the error.
/k
"Edith Barra" <[email protected]> wrote in message
news:3ea594cc$[email protected]..
The error persist.
Help me!!
Tks.
Edy
"Karthik V" <[email protected]> wrote:
Try modifying your uri value to http://localhost:7001/Menu.xml
Substitute correct port and docroot for the xml location.
/k
"Edith Barra" <[email protected]> wrote in message
news:3ea572aa$[email protected]..
How I can read an xml file with SAX or DOM into a war file?. I haveWLS
6.1 SP4
with WLI2.1 SP2.
I can read a xml file, but when I create a war file, the aplicationdoes
not find
the xml file. When it tries to find it, it looks on the path but
not
on
the war
which contains the xml file needed.
This is the instruction given:
String uri = "Menu.xml";
DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse( uri );
And the error message displayed is:
File "file:///c:/bea/wli21/Memu.xml" not found
Coments please!!
Edy -
Is there any methodology whereby a file can be exported, or saved, as a Tab Delimited File?
ThanksSelect All
Copy
Paste in a Pages document
Export as text.
Other way (my preffered one) :
Select All
Copy
run this Script :
--[SCRIPT clipboard2textFile]
Enregistrer le script en tant que Script :clipboard2textFile.scpt
déplacer le fichier créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:
Copiez la table à exporter dans le Presse-papiers.
menu Scripts > clipboard2textFile
Le script créera un fichier TSV (valeurs séparées par TAB).
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
+++++++
Save the script as a Script :clipboard2textFile.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:
Copy the table to export into the clipboard
menu Scripts > clipboard2textFile
The script will create a TSV file (Tab separated values).
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
+++++++
Yvan KOENIG (VALLAURIS, France))
2009/07/07
2010/01/10 : Corrigé quelques coquilles dans les explications
--=====
on run
try
set enTexte to the clipboard as text
set fName to (do shell script "date " & quote & "+_%Y%m%d-%H%M%S" & quote) & "." & "txt"
set p2d to path to desktop
tell application "System Events" to make new file at end of p2d with properties {name:fName}
write enTexte to file ((p2d as text) & fName)
on error
if my parleAnglais() then
error "The clipboard doesn’t contain text data. Maybe you selected a Numbers sheet !"
else
error "Le presse-papiers ne contient pas de données texte. Vous avez peut-être copié une feuille de Numbers !"
end if
end try
end run
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) mardi 16 février 2010 21:57:42 -
Importing fixed width text from a .txt file
I am really struggling to do in Numbers '09 something which I can do easily in Excel.
I have a txt file containing plain text in fixed-width columns which I would like to import into numbers.
I just cannot find a way to do it.
I have tried using the Insert/choose menu item - but it won't take .txt files.
I have tried to copy/paste the data, but it get's pasted into a single column.
The data consists of many lines like this:
Part Value Device Package Library Sheet
A-IN JST-2.0-4 JST-2.0-4 JST-20M KMILLAR 1
A-IN JST-2.5-4 JST-2.5-4 JST-25M KMILLAR 1
A-IN JST-2.8-4 JST-2.8-4 JST-28M KMILLAR 1
(and so on....)
(Each column is an exact number of characters wide, but these forums make that hard to see due to the variable spaced fonts).
How can I import this data into numbers?
(Sorry, but I cannot get the data in any other format, such as CSV, the application which exports it only support fixed width colums with spaces for padding).
Many thanks in advance,
KennyHere is a script treating the case of fixed widths values.
--[SCRIPT fixedwidth_values_toTSV.scpt]
Enregistrer le script en tant que Script : fixedwidth_values_toTSV.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
aller au menu Scripts , choisir Numbers puis choisir fixedwidth_values_toTSV
Choisir un fichier texte.
Le script détermine la largeur des différentes colonnes puis remplace les groupes séparateurs par des caractères TAB.
Le résultat est passé dans le presse-paiers et est enregistré à la place du contenu initial.
Vous pouvez alors
(1) coller dans le document de votre choix
(2) ouvrir le fichier texte modifié dans Numbers qui accepte sans broncher les ficiers .txt.
Utilisation alternative : enregistrer le script en tant que Progiciel (Application sous 10.6.x)
Glisser-déposer l'icône d'un fichier texte sur celle de l'application lancera le traitement voulu.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
Sous 10.6.x,
aller dans le panneau "Général" du dialogue Préférences de l'Éditeur Applescript
puis cocher la case "Afficher le menu des scripts dans la barre des menus".
--=====
Save the script as a Script: fixedwidth_values_toTSV.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
go to the Scripts Menu, choose Numbers, then choose "fixedwidth_values_toTSV"
Choose a text file.
The script scan the file's contents to extract the width of every column then it replace the separator groups by TAB characters.
The result is passed to the clipboard and is written in the original file.
So you may :
(1) paste in the document of your choice
(2) open the modified text file with Numbers which is fair enough to do that.
An alternate track is to save the script as an Application Package (Application under 10.6.x)
Drag and drop the icon of a text file on the application's one will do the job.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2010/08/19
--=====
on run
set un_fichier to choose file with prompt "Choose e text file…" of type {"public.plain-text"} without invisibles
my commun(un_fichier)
end run
--=====
on open (sel)
set un_fichier to item 1 of sel
tell application "System Events" to set type_ID to type identifier of disk item ("" & un_fichier)
if type_ID is "public.plain-text" then my commun(un_fichier as alias)
error "The file “" & un_fichier & "” isn’t a text file !"
end open
--=====
on commun(le_fichier)
set le_contenu to read le_fichier
set le_contenu to "azer ertyuio wxcv dfghj
qszaed dc fghj mlkjhgf nbvcxw
aqwzsx edcrfv tg byhn aaaaaaa "
set listedelistes to {}
set plusgrandelongueur to 0
set pluspetitelongueur to 999999
set listelignesbrutes to paragraphs of le_contenu
repeat with refd_uneligne in listelignesbrutes
set maybe to contents of refd_uneligne
set maybe2 to count of maybe
if maybe2 > plusgrandelongueur then set plusgrandelongueur to maybe2
if maybe2 < pluspetitelongueur then set pluspetitelongueur to maybe2
copy my decoupe(maybe, space) to end of listedelistes
end repeat
set differencedelongueur to plusgrandelongueur - pluspetitelongueur
set des_espaces to space
repeat differencedelongueur times
set des_espaces to des_espaces & space
end repeat
set largeur1 to 0
repeat with refd_uneligne in listedelistes
set maybe to length of first item of refd_uneligne
if maybe > largeur1 then set largeur1 to maybe
end repeat
set liste_finale to {}
repeat with refd_uneligne in listelignesbrutes
set maybe to contents of refd_uneligne
set maybe2 to text 1 thru largeur1 of maybe
repeat while maybe2 ends with space
set maybe2 to text 1 thru -2 of maybe2
end repeat
copy maybe2 to end of liste_finale
copy text (largeur1 + 2) thru plusgrandelongueur of (maybe & des_espaces) to contents of refd_uneligne
end repeat
Enter the bigger loop *)
set cest_Lafin to false
repeat
Deprieve the stored rows of the treated column's items *)
set flag to 0
repeat
set flag to flag + 1
set flag2 to 0
repeat with refd_uneligne in listelignesbrutes
if "" & character flag of contents of refd_uneligne is space then set flag2 to flag2 + 1
end repeat
if flag2 < (count of listelignesbrutes) then exit repeat
end repeat
repeat with refd_uneligne in listelignesbrutes
copy text flag thru -1 of contents of refd_uneligne to contents of refd_uneligne
end repeat
Prepare the extraction of next column *)
repeat with refd_uneligne in listelignesbrutes
copy my decoupe(contents of refd_uneligne, space) to end of listedelistes
end repeat
Extract the width of the column to treat *)
set largeur1 to 0
repeat with refd_uneligne in listedelistes
set maybe to length of first item of refd_uneligne
if maybe > largeur1 then set largeur1 to maybe
end repeat
Extract the column's values *)
repeat with i from 1 to count of listelignesbrutes
set maybe to contents of item i of listelignesbrutes
set maybe2 to text 1 thru largeur1 of maybe
repeat while maybe2 ends with space
set maybe2 to text 1 thru -2 of maybe2
end repeat
copy (contents of item i of liste_finale) & tab & maybe2 to item i of liste_finale
try
copy text (largeur1 + 2) thru -1 of maybe to item i of listelignesbrutes
on error
set cest_Lafin to true
end try
end repeat -- i
if cest_Lafin then exit repeat
end repeat -- bigger loop
set le_contenu to my recolle(liste_finale, return)
set the clipboard to le_contenu
set eof of le_fichier to 0
write le_contenu to le_fichier
end commun
--=====
on decoupe(t, d)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
--=====
on recolle(l, d)
local oTIDs, t
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end recolle
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) vendredi 20 août 2010 12:44:33 -
I want attach my PDF file on my web dynpro view
I have read in this forum about my problem the using of IFrame element but don't work.
Please help me, thanksI guess you could avoid such problems using mapping. Here's some example code, modified from an example:
// Original code from 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
static int length = 0x8FFFFFF; // 128 Mb
public static void mapThis (String file) throws Exception {
MappedByteBuffer out = new RandomAccessFile(file, "rw")
.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, length);
byte b;
if(!out.isLoaded()) out.load();
for (int i = 0; i < length; i++) {
b = out.get(i);
manipulate(b);
As for Bertram's solution, couldn't get it to work properly in a dynamic use case - I'm getting the input stream from IResource, and I get a ClassCastException everytime I use something different from InputStream. With that problem comes another one: InputStream.read() consuming the first byte from the file, which is a problem when dealing with PDF and DOC files, for example. Since I know the users are opening PDF files, made a quick-and-dirty workaround by inserting manually the missing byte. Really dirty one, actually - the byte changes with the file format. Below is the code I used - it works, but I'd love to see a different workaround.
public void openFile( )
//@@begin openFile()
//KM files are shown in a table
//get index of selected table row
int i = wdContext.nodeTableContent().getLeadSelection();
//get the name of the according object (resource)
String name = wdContext.nodeTableContent().getTableContentElementAt(i).getObjectName();
String path = wdContext.currentContextElement().getPath();
try {
RID pathRID = RID.getRID(path"/"name);
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
IResourceContext resourceContext = new ResourceContext(ep5User);
com.sapportals.wcm.repository.IResource resource = ResourceFactory.getInstance().getResource(pathRID, resourceContext);
InputStream in = null;
in = resource.getContent().getInputStream();
int bSize = 10 * 1024;
byte[] bArr = new byte[bSize];
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
int offset = 0;
int data;
//dirty!
String ext = name.substring(name.length()-3);
if("pdf".equalsIgnoreCase(WDWebResourceType.getWebResourceTypeForFileExtension(ext).getFileExtension())) {
byte b = '%';
baos.write(b);
while ( (data=in.read(bArr)) != -1)
baos.write(bArr);
IWDAttributeInfo pdfAttributeInfo = wdContext.getNodeInfo().getAttribute(IPrivateKMBrowserAppCompView.IContextElement.PDF_RESOURCE);
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) pdfAttributeInfo.getModifiableSimpleType();
binaryType.setFileName(name);
binaryType.setMimeType(WDWebResourceType.getWebResourceTypeForFileExtension(ext));
wdContext.currentContextElement().setPDFResource(baos.toByteArray());
} catch (Exception e) {
//@@end -
Import a CSV file into specific cells
Hello,
I have created a simple Numbers template and I want to import a csv file with its values entering specific cells in an automated way.
I think the best way to automate this process would be an AppleScript that does the following:
Selects the csv file;
Parses the values inserting them into the the Numbers template i.e. value1 to cell B2, value2 to cell B3 etc.
Unfortunately I know very little about AppleScript, does anyone have any experience in this area that they could pass on?
My idea would be to place the csv values in an array, and loop through the array entering the values in B2, B3 etc.
Many thanks in advance!
DougieHere is a script doing the full job in a single call.
--{code}
--[SCRIPT csv-to-selected-cell]
Enregistrer le script en tant que Script : csv-to-selected-cell.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Bibliothèque:Scripts:Applications :Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner la première cellule du bloc où vous souhaitez insérer les valeurs extraites d'un fichier CSV.
Aller au menu Scripts , choisir Numbers puis choisir “csv-to-selected-cell”
Le script demande de naviquer jusqu’au fichier CSV.
Il en lit le contenu,
remplace les séparateurs (";" ou ",") par des TABs
copie les données dans le presse-papiers
colle dans la table.
--=====
L’aide du Finder explique:
L’Utilitaire AppleScript permet d’activer le Menu des scripts :
Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case “Afficher le menu des scripts dans la barre de menus”.
Sous 10.6.x,
aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
--=====
Save the script as a Script: csv-to-selected-cell.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select the first cell of the block where values extracted from a CSV file must be inserted.
Go to the Scripts Menu, choose Numbers, then choose “csv-to-selected-cell”
The script urge you to navigate to the CSV file.
It read its contents,
replace the delimiters (";" or ",") by TAB chars
copy the datas in the clipboard
paste in the table.
--=====
The Finder’s Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the “Show Script Menu in menu bar” checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2012/01/18
--=====
on run
local dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2, lesValeurs
my activateGUIscripting()
Extract parameters describing the target cell *)
set {dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
Choose the source CSV file *)
choose file of type {"csv"}
Get the file’s contents *)
set lesValeurs to read result
Grab the delimiter in use *)
if lesValeurs contains ";" then
else
end if
Replace the delimiter in use by TAB *)
my remplace(lesValeurs, result, tab)
Move the 'normalized' datas to the clipboard *)
set the clipboard to result
Reset the target cell in case something changed *)
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
set selection range to range (name of cell colNum1 of row rowNum1)
end tell
Paste matching style *)
my raccourci("Numbers", "v", "cas")
end run
--=====
set { dName, sName, tName, rowNum1, colNum1, rowNum2, colNum2} to my get_SelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
on get_SelParams()
local d_Name, s_Name, t_Name, row_Num1, col_Num1, row_Num2, col_Num2
tell application "Numbers" to tell document 1
set d_Name to its name
set s_Name to ""
repeat with i from 1 to the count of sheets
tell sheet i to set maybe to the count of (tables whose selection range is not missing value)
if maybe is not 0 then
set s_Name to name of sheet i
exit repeat
end if -- maybe is not 0
end repeat
if s_Name is "" then
if my parleAnglais() then
error "No sheet has a selected table embedding at least one selected cell !"
else
error "Aucune feuille ne contient une table ayant au moins une cellule sélectionnée !"
end if
end if
tell sheet s_Name to tell (first table where selection range is not missing value)
tell selection range
set {top_left, bottom_right} to {name of first cell, name of last cell}
end tell
set t_Name to its name
tell cell top_left to set {row_Num1, col_Num1} to {address of its row, address of its column}
if top_left is bottom_right then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
tell cell bottom_right to set {row_Num2, col_Num2} to {address of its row, address of its column}
end if
end tell -- sheet…
return {d_Name, s_Name, t_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end tell -- Numbers
end get_SelParams
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
on decoupe(t, d)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
--=====
replaces every occurences of d1 by d2 in the text t
on remplace(t, d1, d2)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d1
set l to text items of t
set AppleScript's text item delimiters to d2
set t to "" & l
set AppleScript's text item delimiters to oTIDs
return t
end remplace
--=====
on activateGUIscripting()
(* to be sure than GUI scripting will be active *)
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true
end tell
end activateGUIscripting
--=====
==== Uses GUIscripting ====
This handler may be used to 'type' text, invisible characters if the third parameter is an empty string.
It may be used to 'type' keyboard raccourcis if the third parameter describe the required modifier keys.
I changed its name « shortcut » to « raccourci » to get rid of a name conflict in Smile.
on raccourci(a, t, d)
local k
activate application a
tell application "System Events" to tell application process a
set frontmost to true
try
t * 1
if d is "" then
key code t
else if d is "c" then
key code t using {command down}
else if d is "a" then
key code t using {option down}
else if d is "k" then
key code t using {control down}
else if d is "s" then
key code t using {shift down}
else if d is in {"ac", "ca"} then
key code t using {command down, option down}
else if d is in {"as", "sa"} then
key code t using {shift down, option down}
else if d is in {"sc", "cs"} then
key code t using {command down, shift down}
else if d is in {"kc", "ck"} then
key code t using {command down, control down}
else if d is in {"ks", "sk"} then
key code t using {shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
key code t using {command down, shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "a" then
key code t using {command down, shift down, option down}
end if
on error
repeat with k in t
if d is "" then
keystroke (k as text)
else if d is "c" then
keystroke (k as text) using {command down}
else if d is "a" then
keystroke k using {option down}
else if d is "k" then
keystroke (k as text) using {control down}
else if d is "s" then
keystroke k using {shift down}
else if d is in {"ac", "ca"} then
keystroke (k as text) using {command down, option down}
else if d is in {"as", "sa"} then
keystroke (k as text) using {shift down, option down}
else if d is in {"sc", "cs"} then
keystroke (k as text) using {command down, shift down}
else if d is in {"kc", "ck"} then
keystroke (k as text) using {command down, control down}
else if d is in {"ks", "sk"} then
keystroke (k as text) using {shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "k" then
keystroke (k as text) using {command down, shift down, control down}
else if (d contains "c") and (d contains "s") and d contains "a" then
keystroke (k as text) using {command down, shift down, option down}
end if
end repeat
end try
end tell
end raccourci
--=====
--[/SCRIPT]
--{code}
Yvan KOENIG (VALLAURIS, France) mercredi 18 janvier 2012
iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k
My iDisk is : http://public.me.com/koenigyvan -
Parse log file using powershell
Hi,
Am pretty new to Powershell and would require anyone of your assistance in setting up a script which parse thru a log file and provide me output for my requirements below.
I would like to parse the Main log file for Barra Aegis application(shown below) using powershell.
Main log = C:\BARRALIN\barralin.log
Model specific log = C:\BARRALIN\log\WG*.log
Requirements :
1. scroll to the bottom of the log file and look for name called "GL Daily" and see the latest date which in the example log below is "20150203"
note : Name "GL Daily" and date keep changing in log file
2. Once entry is found i would like to have a check to see all 3 entries PREPROCESS, TRANSFER, POSTPROCESS are sucess.
3. If all 3 are success i would like to the script to identify the respective Model specific log number and print it out.
E.g if you see the sample log below for "GL Daily", it is preceded by number "1718" hence script should append the model log path with "WG00" along with 1718, finally it should look something like this C:\BARRALIN\log\WG001718.log.
4. If all 3 items or anyone of them are in "failed" state then print the same log file info with WG001718.log
Any help on this would be much appreciated.
Thank You.
Main log file :
START BARRALINK Check Auto Update 1716
43006 20150203
Trgt/Arch c:\barralin
PREPROCESS success 0 preprocessor: no error
TRANSFER success 1 Host success: files received
POSTPROCESS success 0 Postprocessor: no error
CONFIRMATION success 2 No Confirm needed
STOP 43105 20150203
START Aegis GL Monthly
1716 43117 20150203
Trgt/Arch K:\barraeqr\aegis\qnt\gleqty
PREPROCESS success 0 preprocessor: no error
TRANSFER success 1 Host success: files received
POSTPROCESS success 0 Postprocessor: no error
CONFIRMATION success 2 No Confirm needed
STOP 44435 20150203
START Aegis UB Daily
1717 43107 20150203
Trgt/Arch K:\barraeqr\aegis\qnt\gleqty
PREPROCESS success 0 preprocessor: no error
TRANSFER success 1 Host success: files received
POSTPROCESS success 0 Postprocessor: no error
CONFIRMATION success 2 No Confirm needed
STOP 44435 20150203
START Aegis GL Daily
1718 44437 20150203
Trgt/Arch K:\barraeqr\aegis\qnt\gleqty
PREPROCESS success 0 preprocessor: no error
TRANSFER success 1 Host success: files received
POSTPROCESS success 0 Postprocessor: no error
CONFIRMATION success 2 No Confirm needed
STOP 50309 20150203
Hi All,
I was writing a function in power shell to send email and i was looking to attach lines as and when required to the body of the email. but am not able to get this done..Here's my code
Function Email ()
$MailMessage = New-Object System.Net.Mail.MailMessage
$SMTPClient = New-Object System.Net.Mail.SmtpClient -ArgumentList "mailhost.xxx.com"
$Recipient = "[email protected]"
If ($MessageBody -ne $null)
$MessageBody = "The details of Barra $strsessionProduct model is listed below
`rHostName : $localhost
`r Model Run Date : $Date
`r Model Data Date : $DateList1
`r`n Click for full job log"+ "\\"+$localhost+"\E$\Local\Scripts\Logs "
$MailMessage.Body = $MessageBody
If ($Subject -ne $null) {
$MailMessage.Subject = $Subject
$Sender = "[email protected]"
$MailMessage.Sender = $Sender
$MailMessage.From = $Sender
$MailMessage.to.Add($Recipient)
If ($AttachmentFile -ne $null) { $MailMessage.Attachments.add($AttachmentFile)}
$SMTPClient.Send($MailMessage)
$Subject = "Hello"
$AttachmentFile = ".\barralin.log"
$MessageBody = "Add this line to Body of email along with existing"
Email -Recipient "" -Subject $Subject -MessageBody $MessageBody -AttachmentFile $AttachmentFile
as you can see before calling Email function i did add some lines to $MessageBody and was expecting that it would print the lines for $MessageBody in Email Function along with the new line. But thats not the case.
I have tried to make $MessageBody as an Array and then add contents to array
$MessageBody += "Add this line to Body of email along with existing"
$MessageBody = $MessageBody | out-string
Even this didnt work for me. Please suggest me any other means to get this done.
THank You
Maybe you are looking for
-
Hi there, is it possible to replicate the content of one iphone on a UK sim card to anotehr iphone with a Spanish sim card and carry both devices, actice, for my work purposes?
-
Replacing System hard drive with a new one. How to get everything over to the new boot drive? Should I use Carbon Copy or does apple have a better untility to do this? I can't get my current system drive (OSX 10.8.3) to start on the first try. I alwa
-
How do I locate column/row (number) selected in applescript
I require a simple script to adjust the column widths of the current selected column only. I want to base it on a script below which I found on the internet. This script adjusts multiple column widths to the value input and adjusts the stub column to
-
Need help on adobe forms?explain in details?
hello experts!!! any body explain about Adobe Forms? wat is Adobe form? purpose? it can work on ecc6.0? pls give me example step by step how to create adobe forms? where i wll get ? and wat is diff.between smartforms & adobeforms?
-
Regarding the FK relation ship (GL ACCOUNT from SKA1)
Hello , i need the GL account no from SKA1 related to bwtar-valuation Type from MSEG. Valuation type :INDIGENOUS GL account no, Business Area, Material Code, Material Description, Valuation type, Quantity, Rate Value Valuation type IMPORTED Sl.No. Bu