OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Subroutine for peeking a variable with copy of value

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
ristoi
General User
General User


Joined: 25 Aug 2009
Posts: 26
Location: Järvenpää

PostPosted: Wed Jul 07, 2010 10:13 am    Post subject: Subroutine for peeking a variable with copy of value Reply with quote

I have used to use 'Print sVariable' line of command if I have need for temporary peeking value at development stage of program code.

There is at least one limitation for that procedure: I cannot get copy of value from Print window.

I know that there is xray and there is slow doubleclick in IDE, but they are not so familiar to me. So I wrote my own "Print sVariable" - routine for looking at the value and possible copy the value. In reality it is InputBox with some ready made features.

This Titta-routine use iKieli function for multilingual UI-text.

So there is some more information about the variable than user can get from plain InputBox or Print. There are among other thing:
- The language code of the active document
- Info if string variable is numeric or suitable as date
- Info about type of variable
- if argument is an array, you can see an example element value

Cancel button stop the program run silently.

What I still want is more info from the struct case.

Changing documents default language from options change at least the language code on window upper bar. If this language is already implemented (both in iKieli and in Titta) this change changes UI texts to that language, except optional "Selite" prompts text.

Words of a new language can be added to end of each Choose list with adding the language code to iKieli. Change of a language with removing old one is easy changing only words and the language code.

Implemented languages: fi et pl es fr de da cs
They are European languages around Baltic and Mediterranean Seas and one from Bohemia. There may be some errors in words.
Default placement of the window is aimed show more document at same time. The coordinates can be changed or removed from the code.

Maybe somebody other too finds this useful or at least can change it so. All kindly comments are welcome (-;

Regards
Risto

Code:


Sub Titta (vParam as Variant, Optional Selite as String)
REM Tämä Titta-rutiini tuottaa kopiointikelpoisen sisältötiedon vParam-argumentista (mikäli mahdollista)
REM Selite sisältää mahdollisen selitteen käyttäjälle, saa olla tyhjä tai puuttua
REM Muistuttaa hieman [Print "Tämä ", JokuLauseke]-komentoa, siis yksinkertaista tulostusta näytölle
REM (RJ)
REM !!! Peruuta-painike keskeyttää ohjelman!!!

DIM s as String,  sArvo as String, sOtsikko as String, sSelite as String
DIM  sUs(10) as String, sT as String, sKTunnus as String
DIM lTNro as Long, lAraja as Long,  lYraja as Long, lInd as Long
DIM iK as Integer
   
   REM Haetaan käytettävä (asiakirjan) kieli
   iK = iKieli(sKTunnus)
   
   REM sOtsikko saa tässä arvon:
   REM iK->   --------1-----------2----------3----------4--------5-------6-------7----...
   sT=Choose(iK, "Tarkastele", "Vaata", "Przegladac", "Vista", "Vue", "Profil", "Se",_
   "Pohled", "Look at", "?")
   sOtsikko= "  " & sT & "              | " & sKtunnus & " |"
   
   REM käsitellään puuttuvan argumentin tapaus
   IF IsMissing(Selite) then    
      sSelite =""
   else
      sSelite = Selite
   EndIf
   
   IF IsUnoStruct(vParam) then
      sUs(1) = "UNOStruct "
   EndIf
   
   IF IsArray(vParam) then
      'Huomioidaan 1. ulottuvuus, elementti nro 0
      lYraja = Ubound(vParam)
      lAraja = Lbound(vParam)
      sUs(2) = "Array, "
      IF lYraja-lAraja > 0 then
         lInd = lAraja + 1
      else
         lInd = lAraja
      EndIf
      
      If lYraja > -1 then
         sT=Choose(iK, "esimerkkialkio", "näide_element", "element_przyklad",_
         "ejemplo_elemento",   "élément_par_exemple", "Beispiel_Element",_
         "eksempel_element", "Napríklad_element", "Element_example", "?")
         sUs(4) = sT & "("               
         sUs(6) = ")"
      else
         sArvo=""
         lInd=0
      EndIf
      sUs(5) = lInd
   EndiF
   
   lTNro = VarType(vParam)                  
   
   If sArvo ="" And lTNro <> 9 AND lYraja > -1 then
       sArvo = vParam(lInd)   
   else
      sUs(5)=""   
   EndIf
   
   If sArvo<>"" then
      If IsNumeric(sArvo) then sUs(8) = ", IsNumeric"
       IF IsDate(sArvo) then sUs(9) =  ", IsDate"
      If sUs(5) =""  then
          sT=Choose(iK, "muuttuja", "muutuja", "zmienna", "variable", "variable", "Variable",_
          "variable", "promenlivý", "Variable", "?")
          sUs(5)= sT
       EndIf
   else
      If sUs(5)=""  then
         sT=Choose(iK, "ei esitettävää", "ei esitatavat", "nie przedstawil", "no presentó",_
         "pas présenté", "nicht vorgelegt", "ikke forelagt", "nejsou prezentovány", "nothing to show", "?")
         sUs(5)=sT
      EndIf
   EndIf
   sUs(3) = "["
   sUs(7) = "]"
   s=Join(sUs(),"")                           'Yhdistetään merkkijonotaulukko
   REM kääritään sArvo hakasulkeisiin
   sArvo="[" & sArvo  & "]"
   REM Muodostetaan selite
   s = "TypeName & VarType: " & typename(vParam) & " & " & lTNro & Chr(13) & s & Chr(13) & sSelite
   
   sArvo = InputBox(s, sOtsikko, sArvo, -8000,320)   ',30000,30000 ->esitetään näytön oikeassa alakulmassa
   IF sArvo = "" then Stop                        'Keskeytys Peruuta-painikkeella   
End Sub ' Titta

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group