Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    come semplificare ciclo do...

    -------------------------------------------------------------
    Dim j
    For j=1 to P

    if j=1 then

    if totrec<3 then
    totrec1=totrec
    else totrec1=3
    end if

    for i=0 to totrec1-1

    response.write thetext(i)
    response.write "
    "
    response.write CODCORSOX(i)
    response.write "
    "

    next

    end if

    if j=2 then

    if totrec<6 then
    totrec2=totrec
    else totrec2=6
    end if

    for i=3 to totrec2-1
    response.write thetext(i)
    response.write "
    "
    response.write CODCORSOX(i)
    response.write "
    "

    next

    end if

    next

    -----------------------------------------------------------
    sicome nel ciclo j varia da 1 a 50, come si può semplificare per non riscrivere 50 volte il codice?

  2. #2
    se la funzione per ogni valore di j fosse la stessa il problema nn sarebbe tale in quanto potresti popolare un array di valori a cui paragonare j

    if j=tuoarray(j) then...ecc...ecc

    ma visto che per ogni valore la funzione cambia...mi sa che devi scriverla P volte!

    a meno che la funzione
    Codice PHP:
    if totrec<3 then
    totrec1
    =totrec
    else totrec1=3
    end 
    if

    for 
    i=0 to totrec1-1

    response
    .write thetext(i)
    response.write "
    "
    response.write CODCORSOX(i)
    response.write "
    "

    next 
    sia in funzione di 3...spero di non aver capito male

    in quel caso il tuo script potresti semplificarlo così
    Codice PHP:
    For j=1 to ubound(tuoarray)'praticamente P ma così stai + tranquillo che nn  sfori

    if j=tuoarray(j) then

    if totrectotale<tuoarray(j)*3 then
    totrec(j)=totrectotale
    else totrec(j)=tuoarray(j)*3
    end if

    for i=0 to totrec(j)-1

    response.write thetext(i)
    response.write "
    "
    response.write CODCORSOX(i)
    response.write "
    "

    next

    end if

    next 
    ovviamente totrec() deve essere un array e tuoarray() devi prima popolarlo da 1 a P
    l'unica cosa che nn so come gestire è il tuo totrectotale (che io ho rinominato) che a me pare una variabile globale ma nn so come intendi utilizzare il tuo script
    ...Ignorance is bliss...

  3. #3

    trovata la soluzione...

    ...visto che ho rotto tanto con questa semplificazione, adesso che ho la soluzione la metto sperando che possa servire a qualcuno:

    <%
    Dim P
    P=FIX(totrec/3-0.01)
    Response.Write "P:"
    Response.Write P
    Response.Write "
    "
    %>
    <%Dim j

    For j=0 to P
    X=(3*j-3)+3
    Y=3*j+2

    for i=X to Y

    response.write thetext(i)
    response.write "
    "
    response.write CODCORSOX(i)
    response.write "
    "

    Response.Write "X:"
    Response.Write X
    Response.Write "
    "

    Response.Write "Y:"
    Response.Write Y
    Response.Write "
    "

    Response.Write "TOTREC:"
    Response.Write totrec
    Response.Write "
    "

    Response.Write "i:"
    Response.Write i
    Response.Write "
    "

    on error resume next

    next

    next
    %>

    grazie a tutti...
    Subroutine72


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.