Autore Topic: [Risolto]Problema Out of Bounds  (Letto 1109 volte)

Offline Mefrio

  • Grande Gambero
  • ***
  • Post: 203
    • Mostra profilo
[Risolto]Problema Out of Bounds
« il: 01 Febbraio 2011, 17:20:00 »
Ragazzi ho questo evento
Codice: gambas [Seleziona]
  DIM framebuffer, xrandr, xrandr2, risoluzione, boot, uvesafb, stringa AS String
  DIM sframebuffer, sxrandr, sxrandr2, sboot AS NEW String[]
  DIM i AS Integer = 0

  
  SHELL "xterm -e 'sudo apt-get install hwinfo v86d" WAIT
  SHELL "xterm -e 'sudo hwinfo --framebuffer > ~/.Plymouth_Manager_1.1/temp/frame'" WAIT
  framebuffer = File.Load("~/.Plymouth_Manager1.2/temp/frame")
  sframebuffer = Split(framebuffer, "\n")
  
  SHELL "xrandr" TO xrandr
  sxrandr = Split(xrandr, "\n")
  sxrandr2 = Split(sxrandr[0], " ")
  
  sxrandr2.Delete(0, 7)
  sxrandr2.Delete(3, 4)
  xrandr2 = sxrandr2[0] & sxrandr2[1] & sxrandr2[2]
  risoluzione = Replace(xrandr2, ",", "")
  PRINT risoluzione
  
  boot = Trim(File.Load("~/.Plymouth_Manager1.2/Settings/boot.txt"))
  
  SHELL "cp /etc/default/" & boot & " ~/.Plymouth_Manager1.2/temp" WAIT
  
  SHELL "mv ~/.Plymouth_Manager1.2/temp/" & boot & " ~/.Plymouth_Manager1.2/temp/grub" WAIT
  
  stringa = File.Load("~/.Plymouth_Manager1.2/temp/grub")
    
  sboot = Split(stringa, "\n")
  WHILE i <= 50
    IF Left(sboot[i], 26) = "GRUB_CMDLINE_LINUX_DEFAULT"
      sboot[i] = "GRUB_CMDLINE_LINUX_DEFAULT='quiet splash nomodeset video=uvesafb:mode_option=" & risoluzione & "-24,mtrr=3,scroll=ywrap'"
      TextArea2.Text = TextArea2.Text & sboot[i] & "\n"
    ENDIF
    IF Left(sboot[i], 12) = "GRUB_GFXMODE"
      sboot[i] = "GRUB_GFXMODE=" & risoluzione
      TextArea2.Text = TextArea2.Text & sboot[i] & "\n"
    ENDIF
    IF Left(sboot[i], 19) = "GRUB_GFXPAYLOAD_LINUX"
      sboot[i] = ""
      TextArea2.Text = TextArea2.Text & sboot[i] & "\n"
    ENDIF
    TextArea2.Text = TextArea2.Text & sboot[i] & "\n"
    i = i + 1
   WEND  
  
   File.Save(User.Home & "/boot", TextArea2.Text)
  
   uvesafb = "uvesafb mode_option=" & risoluzione & "-24 mtrr=3 scroll=ywrap"
   File.Save(User.Home & "/uvs", uvesafb)
  
   SHELL "xterm -e 'sudo mv ~/boot /etc/default/" & boot & " && mv ~/uvs /etc/initramfs-tools/modules && echo FRAMEBUFFER=y | sudo tee /etc/initramfs-tools/conf.d/splash'" WAIT
   SHELL "xterm -e 'sudo update-" & boot & "'" WAIT
   SHELL "sudo update - initramfs - u" WAIT
   SHELL "rm boot && rm uvs" WAIT

sembra tutto fatto per bene però alla riga
Codice: gambas [Seleziona]
IF Left(sboot[i], 26) = "GRUB_CMDLINE_LINUX_DEFAULT"

e cioè all'ingresso del ciclo WHILE si blocca e mi dice "Out of bounds"....sapreste indicarmene il motivo?
« Ultima modifica: 01 Febbraio 2011, 21:21:47 da Mefrio »
per quanto io sia messo male, voglio aiutare chi sta peggio di me :D

Offline Ceskho

  • Amministratore
  • Senatore Gambero
  • *****
  • Post: 3.778
  • Vi Veri Veniversum Vivus Vici
    • Mostra profilo
    • Pagina Personale
Re: Problema Out of Bounds
« Risposta #1 il: 01 Febbraio 2011, 17:44:21 »
Sei sicuro che l'array sia pieno?

Offline Mefrio

  • Grande Gambero
  • ***
  • Post: 203
    • Mostra profilo
Re: Problema Out of Bounds
« Risposta #2 il: 01 Febbraio 2011, 20:05:22 »
mmmm...

la variabile stringa è piena ma l'array no...provando a stampare a video sboot[0] non mi da niente! Perchè?
per quanto io sia messo male, voglio aiutare chi sta peggio di me :D

Offline fsurfing

  • Moderatore
  • Senatore Gambero
  • *****
  • Post: 2.484
    • Mostra profilo
Re: Problema Out of Bounds
« Risposta #3 il: 01 Febbraio 2011, 20:12:50 »
la butto li:

forse a gambas non piace questo:

Codice: [Seleziona]
 stringa = File.Load("~/.Plymouth_Manager1.2/temp/grub")  

ma preferisce
Codice: [Seleziona]
 stringa = File.Load(user.home & "/.Plymouth_Manager1.2/temp/grub")  

Offline Mefrio

  • Grande Gambero
  • ***
  • Post: 203
    • Mostra profilo
Re: Problema Out of Bounds
« Risposta #4 il: 01 Febbraio 2011, 20:30:10 »
non funziona neanche così :-\

comunque il modo che ho usato io negli altri casi è funzionante
per quanto io sia messo male, voglio aiutare chi sta peggio di me :D

Offline fsurfing

  • Moderatore
  • Senatore Gambero
  • *****
  • Post: 2.484
    • Mostra profilo
Re: Problema Out of Bounds
« Risposta #5 il: 01 Febbraio 2011, 20:33:55 »
in ogni caso il problema risiede o nel caricamento della stringa o nello split.

fai un debug e bloccalo all' istruzione
Codice: [Seleziona]
 stringa = File.Load("~/.Plymouth_Manager1.2/temp/grub")  
controlla cos acontiene la variabile stringa e di conseguenza il risultato dello split


Offline Mefrio

  • Grande Gambero
  • ***
  • Post: 203
    • Mostra profilo
Re: Problema Out of Bounds
« Risposta #6 il: 01 Febbraio 2011, 20:58:27 »
se io faccio così
Codice: gambas [Seleziona]
  stringa = File.Load("~/.Plymouth_Manager1.2/temp/grub")
    PRINT stringa
  sboot = Split(stringa, "\n")
     PRINT sboot[0]

mi stampa sia l'intero file che la prima riga...ma allora il problema dove sta?
per quanto io sia messo male, voglio aiutare chi sta peggio di me :D

Offline fsurfing

  • Moderatore
  • Senatore Gambero
  • *****
  • Post: 2.484
    • Mostra profilo
Re: Problema Out of Bounds
« Risposta #7 il: 01 Febbraio 2011, 21:14:36 »
a ok
il problema sta nel fatto che non sempre nell' array hai 50 valori , anzi sicuramente ne hai meno ... correggi così

Codice: [Seleziona]
# WHILE i <= sboot.max  
#    IF Left(sboot[i], 26) = "GRUB_CMDLINE_LINUX_DEFAULT" 

Offline Mefrio

  • Grande Gambero
  • ***
  • Post: 203
    • Mostra profilo
Re: Problema Out of Bounds
« Risposta #8 il: 01 Febbraio 2011, 21:21:32 »
ok ho risolto, grazie mille ;)
per quanto io sia messo male, voglio aiutare chi sta peggio di me :D