Snippets
Created by
SeanB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | Object oLineCalc is a ModalPanel
Set Size to 177 246
Property Integer phLabelObj
Property String psTypeFace "Arial"
Property Integer piFontSize 12
Function CreateLineObj Returns Integer
Integer hObj
Get phLabelObj to hObj
If (hObj <>0) Function_Return hObj
Get Create (RefClass(TextBox)) to hObj
Set phLabelObj to hObj
Function_Return hObj
End_Function
Function TextLineLength String sInp Returns Integer
Integer hObj
Integer iLength
Get CreateLineObj to hObj
Set FontPointHeight of hObj to (piFontSize(Self))
Set Typeface of hObj to (psTypeFace(Self))
Set Value of hObj to "xx"
Set Value of hObj to sInp
Get GuiSize of hObj to iLength
Move (low(iLength)) to iLength
Function_Return iLength
End_Function
Function MonitorResolution Returns Number
Number nPos
Integer hObj
Integer iHeight
Get CreateLineObj to hObj
Set Size of hObj to 100 100
Get GuiSize of hObj to nPos
Move (Hi(nPos)) to nPos
If (nPos < 200) Function_Return 1
If (nPos < 300) Function_Return 1.25
If (nPos < 350) Function_Return 1.5
If (nPos < 400) Function_Return 1.75
Move (nPos/200) to nPos
Function_Return nPos
End_Function
Function FormatLineToFixedWidth String sInp Integer iLength Returns String[]
String[] aWords
String[] aRet
Integer iMax
Integer iPos
String sRet
Integer iTestLen
Move (StrSplitToArray(sInp," ")) to aWords
Move (SizeOfArray(aWords)) to iMax
If (sInp="") Move "" to aWords[0]
Move aWords[0] to sRet
For iPos from 1 to (iMax-1)
Move (TextLineLength(Self,sRet+" "+aWords[iPos]+" ")) to iTestLen
If (iTestLen>=iLength) Begin
Move sRet to aRet[SizeOfArray(aRet)]
Move aWords[iPos] to sRet
End
Else Begin
Move (sRet+" "+aWords[iPos]) to sRet
End
Loop
If (sret<>"") Move sRet to aRet[SizeOfArray(aRet)]
Function_Return aRet
End_Function
Function FormatTextToFixedWidth String sInp Integer iLength Returns String[]
String[] aRet
String[] aLines
String[] aTemp
Integer iMax
Integer iPos
String sChar10
Move (Character(10)) to sChar10
Move (StrSplitToArray(sInp,sChar10)) to aLines
Move (SizeOfArray(aLines)) to iMax
For iPos from 0 to (iMax-1)
Move (FormatLineToFixedWidth(Self,aLines[iPos],iLength)) to aTemp
Move (AppendArray(aRet,aTemp)) to aRet
Loop
Function_Return aRet
End_Function
Function LengthForInches Integer iInches Returns Integer
Number nPointSize
Get MonitorResolution to nPointSize
Move (nPointSize*93) to nPointSize
Function_Return (iInches*nPointSize)
End_Function
End_Object
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.